Skip to content

Instantly share code, notes, and snippets.

@AlexWebLab
Forked from DejanBelic/async await ie11.js
Created March 10, 2020 04:02
Show Gist options
  • Save AlexWebLab/17a270fc8e1de3977c0179911ad4db73 to your computer and use it in GitHub Desktop.
Save AlexWebLab/17a270fc8e1de3977c0179911ad4db73 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