Answer the question
In order to leave comments, you need to log in
How to send JSON data to a table?
I need to pass JSON data to a table.
This is a JSON file:
https://jsonplaceholder.typicode.com/users
And this is HTML, CSS:
https://playcode.io/620564/
Answer the question
In order to leave comments, you need to log in
fetch(" https://jsonplaceholder.typicode.com/users ")
.then((res) => res.json())
.then((data) => {
createUser(data);
});
function createUser(users) {
const tbl = document.querySelector("#tbl");
users.forEach((user) => {
const tr = `
${user.name} ${user.username} ${user.email}
`;
tbl.innerHTML += tr
});
}
is the fastest implementation and ${user. ... } substitute whatever you want
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question