December 2019
Intermediate to advanced
598 pages
12h 21m
English
The getUnansweredQuestions function doesn't simulate a web API call very well because it isn't asynchronous. In this section, we'll change this. Follow these steps to do so:
const wait = (ms: number): Promise<void> => { return new Promise(resolve => setTimeout(resolve, ms));};
This function will wait asynchronously for the number of milliseconds we pass into it. The function uses the native JavaScript setTimeout function internally, so that it returns after the specified number of milliseconds.
Notice the function returns a Promise object.
Read now
Unlock full access