$.getJSON('http://localhost:5000/api/users', function(data) {
for(var i=0; i<data.users.length; i++){
$('tbody').append(
'<tr><td>' + data.users[i].id +
'</td><td>' + data.users[i].name +
'</td><td>' + data.users[i].username +
'</td><td>' + data.users[i].email +
'</td><td>' + data.users[i].phone +
'</td><td>' + data.users[i].website + '</td><tr>');
}
});
$.getJSON('http://localhost:5000/api/users', function(data){
console.log(data);
});
<table id="users">
<thead>
<tr>
<td>id</td>
<td>name</td>
<td>username</td>
<td>email</td>
<td>phone</td>
<td>website</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="script.js"></script>
{
"users": [
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
}
]
}