remove: reject
This commit is contained in:
parent
48daa44ee9
commit
baeba7a8a7
1 changed files with 4 additions and 7 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
||||||
|
|
||||||
function getLatestVersion() {
|
function getLatestVersion() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
// if (typeof milliseconds !== "number") {
|
|
||||||
// throw new Error("milleseconds not a number");
|
|
||||||
// }
|
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
||||||
xhr.open("GET", url);
|
xhr.open("GET", url);
|
||||||
|
|
@ -18,8 +14,9 @@ function getLatestVersion() {
|
||||||
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
||||||
|
|
||||||
resolve(latestVersion);
|
resolve(latestVersion);
|
||||||
} else if (xhr.status !== 200) {
|
} else {
|
||||||
reject(`ERROR: got status ${xhr.status}`);
|
throw new Error(`ERROR: got status ${xhr.status}`);
|
||||||
|
// reject(`ERROR: got status ${xhr.status}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue