s
Size: a a a
s
BD
К
К
К
AG
AG
OJ
К
К
К
AG
AG
const wait = milliseconds => {
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, milliseconds);
});
}
const init = () => {
wait(1000).then(() => {
console.log("Waited 1 second");
});
fetch("https://jsdemo-3f387-default-rtdb.europe-west1.firebasedatabase.app/notifications/new.json")
.then(response => response.json())
.then(data => {
console.log(data);
});
}
init();AG
const init = async () => {
// ❌ This is unexpectedly delaying the fetch call too
await wait(1000);
console.log("Waited 1 second");
const response = await fetch("https://jsdemo-3f387-default-rtdb.europe-west1.firebasedatabase.app/notifications/new.json");
const data = await response.json();
console.log(data);
}
init();К
К
К
К
К
К