Log all http requests at start and end
// FREEBIE
This commit is contained in:
parent
0017f196ef
commit
537f0ceef0
2 changed files with 8 additions and 0 deletions
|
@ -38931,6 +38931,7 @@ TextSecureServer = function () {
|
|||
*/
|
||||
function ajax(url, options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log(options.type, url);
|
||||
var error = new Error(); // just in case, save stack here.
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(options.type, url, true /*async*/);
|
||||
|
@ -38955,12 +38956,15 @@ TextSecureServer = function () {
|
|||
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
||||
}
|
||||
if ( 0 <= xhr.status && xhr.status < 400) {
|
||||
console.log('Success', xhr.status);
|
||||
resolve(result, xhr.status);
|
||||
} else {
|
||||
console.log('Error', xhr.status);
|
||||
reject(HTTPError(xhr.status, result, error.stack));
|
||||
}
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
console.log('Error', xhr.status);
|
||||
reject(HTTPError(xhr.status, null, error.stack));
|
||||
};
|
||||
xhr.send( options.data || null );
|
||||
|
|
|
@ -42,6 +42,7 @@ TextSecureServer = function () {
|
|||
*/
|
||||
function ajax(url, options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log(options.type, url);
|
||||
var error = new Error(); // just in case, save stack here.
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(options.type, url, true /*async*/);
|
||||
|
@ -66,12 +67,15 @@ TextSecureServer = function () {
|
|||
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
||||
}
|
||||
if ( 0 <= xhr.status && xhr.status < 400) {
|
||||
console.log('Success', xhr.status);
|
||||
resolve(result, xhr.status);
|
||||
} else {
|
||||
console.log('Error', xhr.status);
|
||||
reject(HTTPError(xhr.status, result, error.stack));
|
||||
}
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
console.log('Error', xhr.status);
|
||||
reject(HTTPError(xhr.status, null, error.stack));
|
||||
};
|
||||
xhr.send( options.data || null );
|
||||
|
|
Loading…
Add table
Reference in a new issue