From 6b43b788d909ce20f07f29f9f3ccd2f6a8715616 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 10:22:00 +0300 Subject: migrate xhrJson invocations to the new helper --- js/common.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js index dbe1ae3c3..f3fcdd905 100755 --- a/js/common.js +++ b/js/common.js @@ -143,7 +143,7 @@ String.prototype.stripTags = function() { const xhr = { post: function(url, params = {}, complete = undefined) { - console.log("xhr.post:", params); + console.log('xhr.post', '>>>', params); return new Promise((resolve, reject) => { if (typeof __csrf_token != "undefined") @@ -156,6 +156,8 @@ const xhr = { reject(error); }, load: function(data, ioargs) { + //console.log('xhr.post', '<<<', data, ioargs); + if (complete != undefined) complete(data, ioargs.xhr); @@ -176,6 +178,8 @@ const xhr = { reject(e); } + console.log('xhr.json', '<<<', obj); + if (complete != undefined) complete(obj); resolve(obj); @@ -209,21 +213,7 @@ function xhrPost(url, params = {}, complete = undefined) { /* exported xhrJson */ function xhrJson(url, params = {}, complete = undefined) { - return new Promise((resolve, reject) => - xhrPost(url, params).then((reply) => { - let obj = null; - - try { - obj = JSON.parse(reply.responseText); - } catch (e) { - console.error("xhrJson", e, reply); - reject(e); - } - - if (complete != undefined) complete(obj); - - resolve(obj); - })); + return xhr.json(url, params, complete); } /* common helpers not worthy of separate Dojo modules */ -- cgit v1.2.3