Which fix removes the bug?
setTimeout(refresh(), 1000);
- Pass
refreshwithout calling - Pass
1000as the first argument - Wrap
refreshinPromise - Replace it with
setInterval
refresh() runs immediately and its return value is scheduled instead.setTimeout(refresh(), 1000);
refresh without calling1000 as the first argumentrefresh in PromisesetIntervalrefresh() runs immediately and its return value is scheduled instead.