I am trying to redirect the user to the home page after registering (which includes automatic login). However, I keep getting this error. I have no idea why this is happening, and I’ve been trying to fix it for two days. Your help will be greatly appeciate! :’)
Error:
Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Relevant code (i think):
// BACKEND registerController.ts
res.redirect('http://localhost:3000/')
.
// FRONTEND apiHandler.ts
const init = {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
};
const response = await fetch(`http://localhost:4000/api${endpoint}`, init);