mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
+37
-18
@@ -514,30 +514,49 @@ kit.config = kit.config || {};
|
||||
|
||||
self.config.debug && console.log(`Plugin ${self.id}: httpGet ${url}`);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url2 = url;
|
||||
if(self.config.isSetTimestamp){
|
||||
url2 = getUrlWithTimestamp(url);
|
||||
}
|
||||
xhr.open('GET', url2, true);
|
||||
p = fetch(url2, {
|
||||
method: 'GET', redirect: 'follow'
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.ok) {
|
||||
return response.text();
|
||||
}
|
||||
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.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();
|
||||
// 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