Hi,
I have a netlify function running from submission-created.js
So from the client side, I have something like this for the submit event listener:
const processForm = form => {
const data = new FormData(form)
fetch('/', {
method: 'POST',
body: data
}).then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
}
In the lambda function:
somePromise()
.then( data => {
callback(null, {
statusCode: 201,
body: "All done!"
})
})
.catch ( error => {
callback(null, {
statusCode: 500,
body: "Something went wrong! :( "
})
})
When triggering the form, the function seems to deploy and everything seems to be working fine.
However, in my client side eventlistener, I always get a 200 and response.ok=true
Even when the lambda function should be sending a callback with 201 or 500. The function seems to be doing its thing accordingly, if an error is thrown it does hit the catch, so I’m assuming i’m doing something trivial incorrectly?
Any hints and clues would be very much appreciated!