fixing callback function on server side

This commit is contained in:
mati108@gmail.com committed 2018-09-18 12:25:56 -03:00
1 parent 67a74b88c6
commit 565f072dd1
2 files changed
+36 -22

No files matched your search

+25 -19
View File
@@ -35,11 +35,12 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
@@ -53,10 +54,11 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
@@ -71,10 +73,11 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
@@ -92,10 +95,11 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
@@ -112,10 +116,11 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
@@ -131,10 +136,11 @@
callServer(undefined, path + "/NO-LOG", onServerResponse);
function onServerResponse(pServerResponse) {
let response = JSON.parse(pServerResponse);
callBackFunction(response);
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
else
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
}
}
}
+11 -3
View File
@@ -739,6 +739,11 @@ function onBrowserRequest(request, response) {
global.EXCHANGE_NAME = "Poloniex";
global.MARKET = {
assetA: "USDT",
assetB: "BTC"
};
global.EXCHANGE_KEYS = {
"Poloniex": {
"Key": exchangeKey,
@@ -814,12 +819,15 @@ function onBrowserRequest(request, response) {
}
}
function onExchangeResponse(exchangeResponse) {
function onExchangeResponse(err, exchangeResponse) {
/* Delete these secrets before they get logged. */
requestParameters[3] = "";
respondWithContent(JSON.stringify(exchangeResponse), response);
requestParameters[3] = "";
if (err.result === global.DEFAULT_OK_RESPONSE.result)
respondWithContent(JSON.stringify(exchangeResponse), response);
else
respondWithContent(JSON.stringify(err), response);
}
return;