The next step is to create an event handler for when your form is submitted that makes a fetch()
request to the Lambda function you created in steps 1 & 2.
A form submit handler in TypeScript looks like this:
const onSubmit: React.FormEventHandler = async (e) => {
e.preventDefault();
// your code here...
}
It can be linked to the <form>
tag's submit event:
<form onSubmit={onSubmit}>
{/* Your form inputs */}
</form>
For the [Fetch API}(https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) request you can use this as the Lambda function URL:
const functionUrl = 'https://xxxxxxxxx.lambda-url.eu-west-2.on.aws/';
onSubmit
event handler that sets the isBusy
variable in the state to true.subject
in the request body.imageUrl
variable and set isBusy
back to false.