Error Syntaxerror: Unexpected Token < In Json At Position 0
ERROR: core.es5.js?0445:1084 ERROR SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse ( SITUATION: What I am trying to achieve is to pre-
Solution 1:
This error happens when server responds with HTML instead of JSON, particularly when a route is not found and the response is 404 page.
It's unlikely that API has the only route which is mounted at root and available as http://localhost:3000/'+userID
, just because it's not possible for the server to do anything else in this case.
If the route is mounted to some path, like
app.use('/user', userRoutes);
then the requests should be performed to this path as well
returnthis.http.get('http://localhost:3000/user/'+userID)
Post a Comment for "Error Syntaxerror: Unexpected Token < In Json At Position 0"