I have Python Flask (v 1.0.0) backend that returns an http response with status 400 and a custom error message
return Response('My custom errror message', 400)
In my frontend I have an API call to the backend using Fetch API:
fetch(url, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(error => console.log(error));
Since 400 is a BAD REQUEST, fetch goes straight to catch and all I have is TypeError: Failed to fetch message.
How can I get my custom error message in frontend instead of Failed to fetch message? It is visible in the DevTools, so I hope it should be available in fetch somehow?


thenblock?.catch, I think because it is a 400 response andfetchtreats it as an error instantly.