Skip to content

Instantly share code, notes, and snippets.

@DejanBelic
Last active May 11, 2023 15:09
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save DejanBelic/d3b8a008049cd160941f391d326cdaab to your computer and use it in GitHub Desktop.
Save DejanBelic/d3b8a008049cd160941f391d326cdaab 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 :) */
@houyaowei
Copy link

this feature is not support in ie11

https://caniuse.com/#search=async

@vladjap
Copy link

vladjap commented Mar 7, 2019

@houyaowei I think this is not a question, it's explanation how to do it in IE11 :)

@navarrocantero
Copy link

@houyaowei I think this is not a question, it's explanation how to do it in IE11 :)

🤣🤣🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment