I have a problem with creating a function that will stop all the code until it finishes. I thought making async/await. In that function I should make fetch, but it says promise {}, when I return the result code:
const request = async (url) => {
const response = await fetch(url);
const json = await JSON.stringify(response.json());
return json;
}
let tree = request('humans.json');
console.log(tree);
asyncmakes it return a promise automatically.let tree=await request('human.json');make sure it is wrapped inside async function or you can chain.then()to resolve the promiseresponse.json(). It's really not the same as the "duplicate" answers because of that.