I have a piece of code that it works with all browsers except Internet Explorer and Opera.
Here is the code: JSFiddle
(async () => {
var InternalURL = "https://jsonplaceholder.typicode.com/posts/1";
var ExternalURL = "https://jsonplaceholder.typicode.com/comments";
let image, data = await $.getJSON(InternalURL);
if(data) {
// Some code
} else {
// request failed
}
if(!image) {
let data = await $.getJSON(ExternalURL);
if(data) {
// Some code
} else {
// request failed
}
}
// Some code
})();
In IE in points to syntax error in line (async () => {
Any idea why is that and how to fix it?
As I noticed it is a ES6 code, is there anyway to convert a different code that is friendly with older browsers and still gives the same output?