Lets say I am calling an API that gives me the information about a particular movie according to its id
.
I have a function to make an API call:
async function main() {
const movieDetails = await getMovieInfo(movieID)
}
setInterval(main,1000*2)
The API call takes some time to return the movie data, lets say 10 seconds ( this time can of course be variable ) . Now how do I wait for the API to get called before the next main
function call?