techiediaries / angular-express-jwt

Angular 6 with Express.js (json-server) RESTful API Backend Secured with JWT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected token ' in JSON at position 0

manuelricci opened this issue · comments

Hi,

I followed the first lesson of "Build a Real-World Application with Angular", when I run the curl, the server respond with:

POST /auth/login 400 18.653 ms - 1328
SyntaxError: Unexpected token ' in JSON at position 0
at JSON.parse ()
at createStrictSyntaxError (C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\body-parser\lib\types\json.js:158:10)
at parse (C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\body-parser\lib\types\json.js:83:15)
at C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\body-parser\lib\read.js:121:18
at invokeCallback (C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\raw-body\index.js:224:16)
at done (C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\Kille\Desktop\email-angular-course\angular-express-jwt\backend\node_modules\raw-body\index.js:273:7)
at IncomingMessage.emit (events.js:182:13)
at endReadableNT (_stream_readable.js:1081:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

After some useless investigation, I copied your code from this repo, but nothing change. Can you help me?

Hi @techiediaries

After a few tests, I "resolved" the issue by myself.

I written this command:
curl -d '{"email":"Demetris_Bogisich20@gmail.com","password":"nwGiR9PYUOaa_cC"}' -H "Content-Type: application/json" -X POST http://localhost:3000/auth/login

Seems to be not working on powershell and cmd on Windows, but works correctly on Git Bash.