let container = document.createElement('div')
document.body.append(container)
const objRound = obj => {
let user = document.createElement('div')
container.append(user)
for (let key in obj) {
let content = document.createElement('div')
user.append(content)
if (typeof obj[key] === 'object') {
let arr = document.createElement('div')
content.append(arr)
arr.innerText = `${key}: ${objRound(obj[key])}`;
continue;
}
content.innerText = `${key}: ${obj[key]}`;
}
return user;
};
fetch(' https://jsonplaceholder.typicode.com/users')
.then(item => item.json())
.then(item => {
item.forEach(e => {
container.insertAdjacentHTML('beforeEnd', objRound(e));
});
})