Migrated from Redmine #741 | Author: Katsunori Kanda
Status: Feedback | Priority: High, I’m very impatient | Created: 2021-07-26
I got an error on calling getToken API in company public service. Last week it worked but today I got the following error. It seems like receiving a html document.
/Users/hj3406/ws/xxxxxx/test.js:12
if(err) throw err;
^
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse ()
at Object.Utils.JSON.parse (/Users/hj3406/ws/xxxxxx/node_modules/jayson/lib/utils.js:261:22)
at IncomingMessage. (/Users/hj3406/ws/xxxxxx/node_modules/jayson/lib/client/http.js:84:22)
at IncomingMessage.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
const jayson = require('jayson');
const companyLogin = "";
const apiKey = "";
const client = new jayson.client.https({
host: 'user-api.simplybook.me',
path: '/login'
});
const ret = client.request('getToken', [companyLogin, apiKey], (err, res) => {
if(err) throw err;
console.log('getToken: result=' + res.result);
return res.result;
});
testing environment
- node v14.17.1
- library: jayson 2.0.1 https://www.npmjs.com/package/jayson