Skip to content

Instantly share code, notes, and snippets.

@mangowi
Forked from DejanBelic/async await ie11.js
Created February 19, 2021 10:46
Show Gist options
  • Save mangowi/62b8e61bd669a1d49cd6a62f261d7f86 to your computer and use it in GitHub Desktop.
Save mangowi/62b8e61bd669a1d49cd6a62f261d7f86 to your computer and use it in GitHub Desktop.
How to use async await in ie11
// Async await func
async function getTimelineData() {
var response = await fetch('/some-api-url')
return response.json()
}
async function populateTimelineInit() {
var data = await getTimelineData();
new vis.DataSet(data);
}
populateTimelineInit();
// First we transpile code above: https://babeljs.io/repl/
/* After that we have to include 3 polyfills but before code is executed. So beside annoying code regenerator
which is required for async await to work, we also need promise and fetch polyfill.
https://cdn.jsdelivr.net/npm/babel-regenerator-runtime@6.5.0/runtime.js:
https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js:
https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.js:
That's all it's needed :) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment