res.json() throws Unexpected token '<'. The status is 405. The URL turned out to be /api/v1/crud//list-bulk.
Why a mistyped API path returns 405 with HTML
Common question, written up by the Supero team.
Error message
SyntaxError: Unexpected token '<'Linkrev 1
1 answer
Accepted answer
Accepted answer
A path that matches no route returns 405 with an HTML body, not a JSON 404. The double slash means a path variable (here the domain) was empty. Check res.ok before calling .json(), and assert that path variables are set when you build the URL.
Linkrev 1
Your answer
Know the answer? Sign in to post it. It takes an email address and a 6-digit code.
Sign in to answer