mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
+36
-17
@@ -514,30 +514,49 @@ kit.config = kit.config || {};
|
|||||||
|
|
||||||
self.config.debug && console.log(`Plugin ${self.id}: httpGet ${url}`);
|
self.config.debug && console.log(`Plugin ${self.id}: httpGet ${url}`);
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
var url2 = url;
|
var url2 = url;
|
||||||
if(self.config.isSetTimestamp){
|
if(self.config.isSetTimestamp){
|
||||||
url2 = getUrlWithTimestamp(url);
|
url2 = getUrlWithTimestamp(url);
|
||||||
}
|
}
|
||||||
xhr.open('GET', url2, true);
|
p = fetch(url2, {
|
||||||
|
method: 'GET', redirect: 'follow'
|
||||||
xhr.onload = function() {
|
})
|
||||||
if (this.status == 200) {
|
.then(function (response) {
|
||||||
resolve(this.response);
|
if (response.ok) {
|
||||||
} else {
|
return response.text();
|
||||||
console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
|
|
||||||
var error = new Error(this.statusText);
|
|
||||||
error.code = this.status;
|
|
||||||
reject(error);
|
|
||||||
}
|
}
|
||||||
};
|
console.log(`%cPlugin.load(${self.id}): bad status ${response.status}!`, "color: red;");
|
||||||
|
throw ['bad status', response.status, response.statusText].filter().join(' ');
|
||||||
|
}, function(reason){
|
||||||
|
reject('Network Error');
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
resolve(data);
|
||||||
|
}, function(reason){
|
||||||
|
reject(reason);
|
||||||
|
});
|
||||||
|
|
||||||
xhr.onerror = function() {
|
|
||||||
console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
|
|
||||||
reject(new Error("Network Error"));
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.send();
|
// var xhr = new XMLHttpRequest();
|
||||||
|
// xhr.open('GET', url2, true);
|
||||||
|
//
|
||||||
|
// xhr.onload = function() {
|
||||||
|
// if (this.status == 200) {
|
||||||
|
// resolve(this.response);
|
||||||
|
// } else {
|
||||||
|
// console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
|
||||||
|
// var error = new Error(this.statusText);
|
||||||
|
// error.code = this.status;
|
||||||
|
// reject(error);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// xhr.onerror = function() {
|
||||||
|
// console.log(`%cPlugin.load(${self.id}): error load file!`, "color: red;");
|
||||||
|
// reject(new Error("Network Error"));
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// xhr.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user