I created a newsletter form, which is server-side rendered and so far works fine. The form is submitted via an AJAX POST request, but it also has an
action attribute pointing to a custom thank you page, in case the user has JS disabled.
submission-created.js function I successfully call the newsletter service and add a new subscriber. But I also want to tackle a few edge cases, e.g. the newsletter service is down, or the user already exists. I added the checks in the lambda function, and for those cases, I return different HTTP codes/response bodies.
The problem is that in the front end, after submitting the form, I don’t get any of these custom HTTP responses from the lambda function. Instead, I get a HTTP 200 with the contents of the custom thank you page.
Is there a way of getting in the front-end the HTTP response that I return in the lambda function?