Kucoin / kucoin-node-sdk

KuCoin API SDK for Node.js language.
Apache License 2.0
106 stars 53 forks source link

Invalid-Json Response #19

Closed mmsoby closed 2 years ago

mmsoby commented 2 years ago

I apologize as I am not experienced with javascript at all. I keep getting this error. I am running the code from index.js and I have already filled the config file with my API Key, secret, and passphrase. However I keep getting this error. I have looked into it extensively and can't seem to figure it out.

/Users/mustafasoby/node_modules/node-fetch/lib/index.js:273 return Body.Promise.reject(new FetchError(invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); ^ FetchError: invalid json response body at https://sandbox.kucoin.com/api/v1/timestamp? reason: Unexpected token < in JSON at position 0 at /Users/mustafasoby/node_modules/node-fetch/lib/index.js:273:32 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async HttpBase.makeRequest (/Users/mustafasoby/node_modules/kucoin-node-sdk/src/lib/createHttp.js:88:20) at async Object.getTimestamp (/Users/mustafasoby/node_modules/kucoin-node-sdk/src/rest/Others.js:17:10) at async main (/Users/mustafasoby/Documents/coding/JavaScript/KuCoinBot/demo/index.js:6:28) { type: 'invalid-json' }

Node.js v17.0.1 `

mmsoby commented 2 years ago

I think I got passed that by changing the link to https://openapi-sandbox.kucoin.com instead. However I still get a promise error when trying to run index.js.

mmsoby commented 2 years ago

Never mind, I figured it out now. I was using the https://openapi-sandbox.kucoin.io link recommended by the comments in the config.js file. Now I am using https://api.kucoin.com or https://openapi-sandbox.kucoin.com as recommended by the KuCoin API Documentation. I also now realize that api keys created for the main Kucoin api do not work not the sandbox api. I hope this helps someone else who was struggling.