Home JS Async and await to work in internet explorer
Reply: 0

JS Async and await to work in internet explorer

BStill
1#
BStill Published in 2017-12-06 21:56:40Z

I have already gotten my project to work on with async/await in every other browser, but apparently its not compatible in IE.

(async function () {
  try {
    await getLayers();
  }
  catch (err) {
    console.error(err)
  }
}());

which calls my other function:

async function getLayers() {  
    const progress = new LoadingOverlayProgress({
    bar     : {
      "background"    : "#e41a1c",
      "top"           : "600px",
      "height"        : "50px"
    },
    text    : {
      "color"         : "black",
      "font-family"   : "monospace",
      "top"           : "575px"
    }});
$.LoadingOverlay("show", {
    custom  : progress.Init()
});
var count = 0;
const interval = setInterval(function(){
  if (count >= 10) {
    clearInterval(interval);
    delete progress;
    $.LoadingOverlay("hide");
    return;
  }
  progress.Update(count);
}, 100);
try {
  $.when(
    await $.getJSON('http://' + ipAddress + '/api/Barriers/barrierGeoJSON', function (data) {
        createLayer(data[0].row_to_json, 'Barrier');
        count += 5;
      }),
     await $.getJSON('http://' + ipAddress + '/api/DistPoints/distPointGeoJSON', function (data) {
        createLayer(data[0].row_to_json, 'Disturbance Points');
        count += 5;
      });
  }
  catch (err) {
    console.error(err);
  }
};

I need help getting this code to run on IE. Is there some sort of polyfill or transpiler that I have to use? I would hate to have to rewrite everything when it already runs smoothly. This is currently running client-side and I could not figure out how to use async--await. Thank you guys in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309308 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO