X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fajax.js;h=eb30330a7b7bb9a77ff1932819bd45af4777c129;hb=afd3240d89a2f6191fe9426960dc0c1667b40c77;hp=5b460784c79a63263259cfd36d1cd6898483168e;hpb=b4de2e730539cadbff94a42eccfb9cb046cbf810;p=vchess.git diff --git a/client/src/utils/ajax.js b/client/src/utils/ajax.js index 5b460784..eb30330a 100644 --- a/client/src/utils/ajax.js +++ b/client/src/utils/ajax.js @@ -2,6 +2,7 @@ import params from "../parameters"; //for server URL // TODO: replace by fetch API ? // https://www.sitepoint.com/xmlhttprequest-vs-the-fetch-api-whats-best-for-ajax-in-2019/ +// Problem: fetch() does not set req.xhr... see access/ajax() security especially for /whoami // From JSON (encoded string values!) to "arg1=...&arg2=..." function toQueryString(data) @@ -37,10 +38,15 @@ export function ajax(url, method, data, success, error) // Plain text (e.g. for rules retrieval) return success(xhr.responseText); } - if (!res_json.errmsg) + if (!res_json.errmsg && !res_json.errno) success(res_json); else - error(res_json.errmsg); + { + if (!!res_json.errmsg) + error(res_json.errmsg); + else + error(res_json.code + ". errno = " + res_json.errno); + } } };