Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <style>
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 100%;
- }
- td, th {
- border: 1px solid #dddddd;
- text-align: left;
- padding: 8px;
- }
- tr:nth-child(even) {
- background-color: #dddddd;
- }
- table, th, td {
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <ul id="users"></ul>
- <script src="https://unpkg.com/axios@0.21.1/dist/axios.min.js"></script>
- <script>
- axios.get('https://jsonplaceholder.typicode.com/users')
- .then(function (res) {
- res.data.forEach(x => {
- document.getElementById('users').innerHTML +=
- '<table border="1" >'+
- '<tr >'+
- '<th>'+ 'ID' + '</th>' +
- '<th>'+ 'Name' + '</th>' +
- '<th>' + 'Username' + '</th>' +
- '<th>' + 'Email' + '</th>' +
- '<th>' + 'Phone Numner' + '</th>' +
- '</tr>' +
- '<tr >'+
- '<td>'+ x.id + '</td>'+
- '<td>'+ x.name + '</td>'+
- '<td>' + x.username + '</td>' +
- '<td>' + x.email + '</td>' +
- '<td>' + x.phone + '</td>' +
- '</tr>' + '<br>' +
- '</table> '
- ;
- });
- })
- .catch(function(err){
- console.log(err);
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement