Ensure that response always has json_ok even if no internet.

This commit is contained in:
voussoir 2021-06-01 17:38:32 -07:00
parent 2f68b800c5
commit 0694073b70
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -85,14 +85,19 @@ function _request(method, url, callback)
*/ */
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
const response = { const response = {
"meta": {"completed": false, "status": 0}, "meta": {
"completed": false,
"status": 0,
"json_ok": false,
"request_url": url,
},
}; };
request.onreadystatechange = function() request.onreadystatechange = function()
{ {
/* /*
readystate values: readystate values:
0 UNSENT 0 UNSENT / ABORTED
1 OPENED 1 OPENED
2 HEADERS_RECEIVED 2 HEADERS_RECEIVED
3 LOADING 3 LOADING
@ -105,7 +110,6 @@ function _request(method, url, callback)
{return;} {return;}
response.meta.status = request.status; response.meta.status = request.status;
response.meta.request_url = url;
if (request.status != 0) if (request.status != 0)
{ {