Promises
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
Functions that are unavoidably long, slow or flaky can do that work already for the user, and just return a Promise. For example, the built-in replacement for XMLHttpRequest that returns promises is called fetch.
let myResponsePromise = fetch("https://example.com")