js react waiting for some other fetch to finish before making another fetch from a different module code example
Example 1: await fetch in react
async function fetchFunction() {
try{
const response = await fetch(`http://url.com`);
const json = await response.json();
}
catch(err) {
throw err;
console.log(err);
}
}
Example 2: fetch('https://www.example.com/index.html') .then(res => res.text()) .then(html => console.log(html));
fetch('https://www.gs1us.org')
.then(res => res.text())
.then(html => console.log(html));