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;
|
||||
|
||||
function getLatestVersion() {
|
||||
return new Promise((resolve, reject) => {
|
||||
// if (typeof milliseconds !== "number") {
|
||||
// throw new Error("milleseconds not a number");
|
||||
// }
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
|
||||
xhr.open("GET", url);
|
||||
|
|
@ -18,8 +14,9 @@ function getLatestVersion() {
|
|||
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
||||
|
||||
resolve(latestVersion);
|
||||
} else if (xhr.status !== 200) {
|
||||
reject(`ERROR: got status ${xhr.status}`);
|
||||
} else {
|
||||
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