![]() Since we've defined all the functions that help us connect and submit our Airtable, we would also want to make sure that we bind this to our handleRequest Worker, as this is what our FETCH request is going to respond with. Then, return the Airtable handleData() function, and pass in our request body as a parameter. ![]() ![]() We would match firstName to first name, lastName to last name, email to email, and so on. Once we create the request body, which will have the fields that we will pass to our Airtable API to create new forms submissions, these fields that we have in our form would have to match with the fields that we want to input them in the Airtable. We would want to create objects out of the parameters that we have, like the first name, the last name, email, subject, and message. This is the ID that we would want to make objects out of. If we open up our form components, under Components, see Form, you can see that the input tags have an ID. After we've gotten that, we would also want to destructure some parameters from the body, but also make those parameters and objects, so we use the Object.formEntry() on the body. Next thing we want to do is create a constant body that will await the requests, and then make that request a form data, which is just a pair of key values. ![]() This will help us check that the only thing possible with this Submit button, is to send information to the Airtable. It would take a request as a parameter and check that if the request method is not equal to a POST, we want to return a response that says the method is not allowed. We would want to call it submitHandler(). Instructor: This function we want to define is an async function that would handle the form submissions. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |