-
Notifications
You must be signed in to change notification settings - Fork 0
/
skills.js
36 lines (35 loc) · 1.14 KB
/
skills.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
document.addEventListener('DOMContentLoaded', () => {
function fetchData() {
fetch('https://gdi-backend.herokuapp.com/api/path/Frontend')
.then(resp => resp.json())
.then(data => renderSkills(data)).catch((err) => {
handleError(err);
})
}
function renderSkills(data) {
const hardContainer = document.querySelector("#hard-skills");
const softContainer = document.querySelector("#soft-skills");
data.forEach((item) => {
if (item.Name === 'hardSkills') {
let skillsArr = item.text.split(",");
skillsArr.forEach((skill) => {
const skillElm = document.createElement('li');
skillElm.innerHTML = skill;
hardContainer.append(skillElm);
})
}
if (item.Name === 'softSkills') {
let skillsArr = item.text.split(",");
skillsArr.forEach((skill) => {
const skillElm = document.createElement('li');
skillElm.innerHTML = skill;
softContainer.append(skillElm);
})
}
})
}
function handleError(err) {
alert(`Could not load data. Please try again later! Err: ${err.message}`)
}
fetchData();
});