It looks like the issue is with the Axios POST request. To debug this, you can start by logging the response from the Axios request. You can do this by adding the following code to the submit() method:
console.log(res);
This will log the response from the Axios request, which should give you more information about what is going wrong. You can also log the letterForm object to make sure that the data is being sent correctly.
If the response from the Axios request is not what you expect, you can try using the axios.post() method with the validateStatus option set to false to see if that helps. This will allow the Axios request to return a response even if the status code is not 200.
axios.post('/api/newsletter', letterForm, { validateStatus: false })
.then(res => {
// ...
})
.catch(err => {
// ...
});
If the response from the Axios request is still not what you expect, you can try using a tool like Postman to make the same request and see what the response is. This will help you to identify any issues with the request itself.
Once you have identified the issue, you can then update the code to handle the response correctly.