-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult.js
29 lines (28 loc) · 870 Bytes
/
result.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
document.addEventListener('DOMContentLoaded', () => {
function fetchData() {
const field = localStorage.getItem('bestField');
console.log(field);
fetch(`https://gdi-backend.herokuapp.com/${field}`)
.then(resp => resp.json())
.then(data => renderDescription(data)).catch((err) => {
handleError(err);
})
}
function renderDescription(data) {
console.log(data);
const descripContainer = document.querySelector("#jobdescrip");
data.forEach((item) => {
console.log(typeof item);
if (item.Name ==='jobDescripMain') {
console.log(item.text);
const p = document.createElement('p');
p.innerHTML = item.text;
descripContainer.append(p);
}
})
}
function handleError(err) {
alert(`Could not load data. Please try again later! Err: ${err.message}`)
}
fetchData();
});