geoffreybauduin / Nodejs-Epitech-API

A small API to request Epitech's intranet using Nodejs
GNU General Public License v2.0
0 stars 0 forks source link

"ip" : xxx.x.xxx.xxx : is not defined #6

Open joltak opened 7 years ago

joltak commented 7 years ago

undefined:2 "ip": "xxx.x.xxx.xxx", ^

SyntaxError: Unexpected token : in JSON at position 9 at Object.parse (native) at EpitechAPIConnector.formatRequest (C:\wamp64\www\my_intra\my_intra\node_modules\epitech-api\build\connector.js:27:19) at Request._callback (C:\wamp64\www\my_intra\my_intra\node_modules\epitech-api\build\connector.js:46:26) at Request.self.callback (C:\wamp64\www\my_intra\my_intra\node_modules\request\request.js:123:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (C:\wamp64\www\my_intra\my_intra\node_modules\request\request.js:1047:14) at emitOne (events.js:101:20) at Request.emit (events.js:188:7) at IncomingMessage. (C:\wamp64\www\my_intra\my_intra\node_modules\request\request.js:998:12) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

I'm on w10 os up-to-date

geoffreybauduin commented 7 years ago

This sounds a lot like a malformed json payload, do you have more context?

joltak commented 7 years ago

No more cotext, i've just added your mod into my project, just change "login_x" and "unix_pwd" by req.body.login and req.body.pwd in my controller, nothing more :/

this is the console.log(connector)

EpitechAPIConnector { login: 'my_login', password: 'my_pwd', isSignedIn: false, settings: EpitechAPISettings {}, stream: undefined, _cookieJar: RequestJar { _jar: CookieJar { store: { idx: {} } } }, request: { [Function: d] get: [Function: d], patch: [Function: d], post: [Function: d], put: [Function: d], head: [Function: d], del: [Function: d], cookie: [Function: d], jar: [Function] } } POST / 200 931.534 ms - 112 undefined:2 "ip": "xxx.x.xxx.xxx",

geoffreybauduin commented 7 years ago

This clearly looks like malformed JSON received from the API. Do you have a way to make sure the JSON you receive is correct? Or maybe a way for me to reproduce the issue ?