Fix 'Hover Provider Example' incorrect Promise syntax

pull/3583/head
Floyd Wang 2 years ago
parent 2f556e3f9d
commit 0b9f3c15d2

@ -31,35 +31,32 @@ monaco.editor.create(document.getElementById("container"), {
function xhr(url) { function xhr(url) {
var req = null; var req = null;
return new Promise( return new Promise(function (c, e) {
function (c, e) { req = new XMLHttpRequest();
req = new XMLHttpRequest(); req.onreadystatechange = function () {
req.onreadystatechange = function () { if (req._canceled) {
if (req._canceled) { return;
return; }
}
if (req.readyState === 4) { if (req.readyState === 4) {
if ( if (
(req.status >= 200 && req.status < 300) || (req.status >= 200 && req.status < 300) ||
req.status === 1223 req.status === 1223
) { ) {
c(req); c(req);
} else { } else {
e(req); e(req);
}
req.onreadystatechange = function () {};
} }
}; req.onreadystatechange = function () {};
}
};
req.open("GET", url, true); req.open("GET", url, true);
req.responseType = ""; req.responseType = "";
req.send(null); req.send(null);
}, }).catch(function () {
function () { req._canceled = true;
req._canceled = true; req.abort();
req.abort(); });
}
);
} }

Loading…
Cancel
Save