J
J
Java Script2020-06-13 13:04:28
JavaScript
Java Script, 2020-06-13 13:04:28

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

1 answer(s)
A
aleks_web_dev, 2020-06-13
@aleks_web_dev

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 question

Ask a Question

731 491 924 answers to any question