Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xhr.onreadystatechange = () => {
if (callback && xhr.readyState === 4) {
this.log_(
'REST Response for ' + url + ' received. status:',
xhr.status,
'response:',
xhr.responseText
);
let res = null;
if (xhr.status >= 200 && xhr.status < 300) {
try {
res = jsonEval(xhr.responseText);
} catch (e) {
warn(
'Failed to parse JSON response for ' +
url +
': ' +
xhr.responseText
);
}
callback(null, res);
} else {
// 401 and 404 are expected.
if (xhr.status !== 401 && xhr.status !== 404) {
warn(
'Got unsuccessful REST response for ' +
url +
' Status: ' +
xhr.onreadystatechange = () => {
if (callback && xhr.readyState === 4) {
this.log_(
'REST Response for ' + url + ' received. status:',
xhr.status,
'response:',
xhr.responseText
);
let res = null;
if (xhr.status >= 200 && xhr.status < 300) {
try {
res = jsonEval(xhr.responseText);
} catch (e) {
warn(
'Failed to parse JSON response for ' +
url +
': ' +
xhr.responseText
);
}
callback(null, res);
} else {
// 401 and 404 are expected.
if (xhr.status !== 401 && xhr.status !== 404) {
warn(
'Got unsuccessful REST response for ' +
url +
' Status: ' +
private appendFrame_(data: string) {
this.frames.push(data);
if (this.frames.length === this.totalFrames) {
const fullMess = this.frames.join('');
this.frames = null;
const jsonMess = jsonEval(fullMess) as object;
//handle the message
this.onMessage(jsonMess);
}
}
get(key: string): unknown {
const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
if (storedVal == null) {
return null;
} else {
return jsonEval(storedVal);
}
}