Hi @estenp,
If you want to log the values in an object then you need to serialize it with JSON.stringify()
. Or if you want a specific value then you can log that, for instance object.key.nested_key
. But if you attempt to log the entire object you’ll get the string interpretation of it and not the values inside.
The event
contains more than just the payload about the form. What you’re looking for is in event.body
The form submission webhook should return the following:
{
"number": 34,
"title": null,
"email": "test@netlify.com",
"name": "test",
"first_name": "test",
"last_name": null,
"company": null,
"summary": "text field",
"body": "text field",
"data": {
"name": "test",
"email": "test@netlify.com",
"random": "this is random",
"message": "text field",
"ip": "195.94.115.46",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"referrer": "https://test-form--futuregerald.netlify.com/form.html"
},
"created_at": "2019-05-23T17:54:55.388Z",
"human_fields": {
"Name": "test",
"Email": "test@netlify.com",
"Random": "this is random",
"Message": "text field"
},
"ordered_human_fields": [{
"title": "Name",
"name": "name",
"value": "test"
}, {
"title": "Email",
"name": "email",
"value": "test@netlify.com"
}, {
"title": "Random",
"name": "random",
"value": "this is random"
}, {
"title": "Message",
"name": "message",
"value": "text field"
}],
"id": "5ce6ff10ea475751de6f0eae",
"form_id": "5c5cb856a1aee4a722a62657",
"site_url": "https://www.myfakesite.com",
"form_name": "contact"
}
I actually recommend that instead of using a named event-triggered function. You rename the function to something else and then trigger it using a form notification webhook. Function logs will be more reliable this way. In your form settings, you should see a notifications section and in there you can create a webhook notification. The webhook will be sent with the payload that I just provided.
Also, note that the event.body
is a JSON string and needs to be parsed into an object.