diff --git a/iot-gateway/pjs/rest.js b/iot-gateway/pjs/rest.js index cf89a2f..067c0ce 100644 --- a/iot-gateway/pjs/rest.js +++ b/iot-gateway/pjs/rest.js @@ -201,7 +201,7 @@ pipy() msg => ( ( /// debug = console.log('query config:', msg?.body?.toString?.()), - resp = JSON.decode(msg?.body), + resp = (msg?.body?.toString?.().charAt(0) === '{') && JSON.decode(msg?.body), ) => ( (msg?.head?.status === 401) ? ( deviceConfig.strapiJwt = null, @@ -240,7 +240,7 @@ pipy() .replaceMessage( msg => ( ( - resp = JSON.decode(msg?.body), + resp = (msg?.body?.toString?.().charAt(0) === '{') && JSON.decode(msg?.body), ) => ( (msg?.head?.status === 200 && resp?.data?.id > 0) ? ( [new Message('OK'), new StreamEnd] diff --git a/iot-gateway/pjs/worker.js b/iot-gateway/pjs/worker.js index e6309c6..29c0809 100644 --- a/iot-gateway/pjs/worker.js +++ b/iot-gateway/pjs/worker.js @@ -56,7 +56,7 @@ pipy({ .replaceMessage( msg => ( msg?.body && ( - _dataJson = JSON.decode(msg?.body), + _dataJson = (msg?.body?.toString?.().charAt(0) === '{') && JSON.decode(msg?.body), (_dataJson?.ts > 0) && ( delete _dataJson.id, _dataJson.created_at = new Date(_dataJson.ts * 1000).toISOString(),