async function getCustomerData() { const url = 'http://localhost:5078/api/user'; const CustomerReposeData = await fetch(
Posted: Sat May 14, 2022 3:06 pm
Hello, In here is a 1 code fetch api from the restful api in
vanilaJS , however, I still need fetch more than 5 source Restful
api Leading to it will delay a 7s to load all content.
=> I pls help me optimize this one by using multithread or
worker ....
To make it run faster.
async function getCustomerData() { const url = 'http://localhost:5078/api/user'; const CustomerReposeData = await fetch(url, init: { method: "GET" contentType: "application/json", headers: { 'Accept': 'application/json', "Content-Type': 'application/json', }, credentials: 'include', mode: 'cors' }) const user_data = await CustomerReposeData.json(); document.querySelector( selectors: "#name").innerHTML = user_data. fullName; document.querySelector( selectors: "#account Number").innerHTML = user_data.primaryAccount.account Number; document.querySelector( selectors: "#primaryBalance").innerHTML = user_data.primaryAccount.accountBalang document.querySelector( selectors: "#savingBalance").innerHTML = user_data.savingsAccount.accountBalance; document.querySelector( selectors: "#image_id").src = user_data.avatar; document.querySelector( selectors: "#imageProfile").src = user_data.avatar; ; - }
vanilaJS , however, I still need fetch more than 5 source Restful
api Leading to it will delay a 7s to load all content.
=> I pls help me optimize this one by using multithread or
worker ....
To make it run faster.
async function getCustomerData() { const url = 'http://localhost:5078/api/user'; const CustomerReposeData = await fetch(url, init: { method: "GET" contentType: "application/json", headers: { 'Accept': 'application/json', "Content-Type': 'application/json', }, credentials: 'include', mode: 'cors' }) const user_data = await CustomerReposeData.json(); document.querySelector( selectors: "#name").innerHTML = user_data. fullName; document.querySelector( selectors: "#account Number").innerHTML = user_data.primaryAccount.account Number; document.querySelector( selectors: "#primaryBalance").innerHTML = user_data.primaryAccount.accountBalang document.querySelector( selectors: "#savingBalance").innerHTML = user_data.savingsAccount.accountBalance; document.querySelector( selectors: "#image_id").src = user_data.avatar; document.querySelector( selectors: "#imageProfile").src = user_data.avatar; ; - }