// api url
const api_url =
“https://employeedetails.free.beeceptor.com/my/api/path”;

// Defining async function
async function getapi(url) {

// Storing response
const response = await fetch(url);

// Storing data in form of JSON
var data = await response.json();
console.log(data);
if (response) {
hideloader();
}
show(data);
}
// Calling that async function
getapi(api_url);

// Function to hide the loader
function hideloader() {
document.getElementById(‘loading’).style.display = ‘none’;
}
// Function to define innerHTML for HTML table
function show(data) {
let tab =
`

Name Office Position Salary

`;

// Loop to access all rows
for (let r of data.list) {
tab += `

${r.name} ${r.office} ${r.position} ${r.salary}

`;
}
// Setting innerHTML as tab variable
document.getElementById(“employees”).innerHTML = tab;
}


Loading…

Registered Employees