Skip to content

Commit

Permalink
Merge pull request #3583 from madcodelife/main
Browse files Browse the repository at this point in the history
Fix 'Hover Provider Example' incorrect Promise syntax
  • Loading branch information
hediet authored Feb 24, 2023
2 parents 9cb6000 + 1e541d6 commit 3b800d8
Showing 1 changed file with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,32 @@ monaco.editor.create(document.getElementById("container"), {

function xhr(url) {
var req = null;
return new Promise(
function (c, e) {
req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req._canceled) {
return;
}
return new Promise(function (c, e) {
req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req._canceled) {
return;
}

if (req.readyState === 4) {
if (
(req.status >= 200 && req.status < 300) ||
req.status === 1223
) {
c(req);
} else {
e(req);
}
req.onreadystatechange = function () {};
if (req.readyState === 4) {
if (
(req.status >= 200 && req.status < 300) ||
req.status === 1223
) {
c(req);
} else {
e(req);
}
};
req.onreadystatechange = function () {};
}
};

req.open("GET", url, true);
req.responseType = "";
req.open("GET", url, true);
req.responseType = "";

req.send(null);
},
function () {
req._canceled = true;
req.abort();
}
);
req.send(null);
}).catch(function () {
req._canceled = true;
req.abort();
});
}

0 comments on commit 3b800d8

Please sign in to comment.