You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello,
Web Components,I Just debugged on-demand loading logic and found something wrong. The code is as follows:
_getJSON(url) {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
function handler() {
if (this.readyState !== 4) {
return;
}
if (this.status === 200) {
resolve(JSON.parse(this.response));
} else {
reject(new Error(this.statusText));
}
}
xhr.open('GET', url);
xhr.onreadystatechange = handler;
xhr.responseType = 'json';
// xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
});
}
Now that xhr. setRequestHeader ('Content - Type', application / json') is set, the return data does not have to be processed by JSON. parse (this. response). Otherwise, what do you think?
The text was updated successfully, but these errors were encountered:
hello,
Web Components,I Just debugged on-demand loading logic and found something wrong. The code is as follows:
_getJSON(url) {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
function handler() {
if (this.readyState !== 4) {
return;
}
if (this.status === 200) {
resolve(JSON.parse(this.response));
} else {
reject(new Error(this.statusText));
}
}
xhr.open('GET', url);
xhr.onreadystatechange = handler;
xhr.responseType = 'json';
// xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
});
}
Now that xhr. setRequestHeader ('Content - Type', application / json') is set, the return data does not have to be processed by JSON. parse (this. response). Otherwise, what do you think?
The text was updated successfully, but these errors were encountered: