I have a basic question on the need/purpose of using async await in front of backend calls?
useEffect(() => {
headerFooter(props.match.params.token)
.then(res => {
setData(res)
setHeaderFooter(res.header, res.footer)
return grabUserInventory(res.user_id)
.then(data => {
setInventory(data)
setRenderedData(data)
setProgress(false)
return getAllOrgs()
.then(data => {
var outputData = data.map(Object.values);
setOrgs(outputData)
})
})
});
});
If my code works completely fine like this (which it does) then why do I see people writing async
and await
for all of their fetch calls? What does this accomplish? When should I do this?