VibeDict

🧩Response isn't JSON (Unexpected token)

What you'll see
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

The code expected data (JSON) but got something else. If it starts with '<', it's usually an error page (HTML) instead of data.

🤔 Why does it happen?

  • The API address is wrong, so a 404 page (HTML) came back
  • The server hit an error and sent back an error page
  • The response is empty

🔧 Try this

  1. In the developer tools' Network tab, click that request and open the Response yourself
  2. Check the API address and the server logs

🤖 Ask your AI like this

I get the error below. Please check what the API returns instead of JSON, and fix the address or the server error. Also add handling that shows the user a helpful message when the request fails. [Paste the full error here]

Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.

Related terms

Other errors in this group