I have the following:
async fetch() {
const res = await axios.get('/api/validate/randomtoken')
if(res.exists) {
await axios.get('/api/users')
}
}
As you can see, I first validate the token, and return back all users. Here I am using two await's.
As per this question: How run async / await in parallel in Javascript, I should use Promise.all(). However, the problem is I need to check if res.exists compulsorily, so I guess I can't use Promise.all()!
I just wanted to know that if the approach which I am currently using is right or not and also if possible how could I use Promise.all() here?