I want to render JSON data in HTML in div with id content in paragraph tags in this format -
ID:XYZ
Username : ABC
Age : Kd
How can I do it ?? I am new in async-await, can someone help me ??
./user.json file
[
{
"id":1002,
"username":"dcode",
"age":30
},
{
"id":1140,
"username":"otheruser",
"age":41
}
]
//My async await
async function loadUsers()
{
const response = await fetch("./user.json");
return response.json();
}
document .addEventListener('DOMContentLoaded',async()=>{
try{
users = await loadUsers();
}
catch (e)
{
console.log("ERROR");
console.log(e);
}
console.log(users);
})