Skip to content

Commit 9456013

Browse files
author
Rich Harris
committed
link to FormData docs
1 parent 8c6d0fd commit 9456013

File tree

2 files changed

+3
-1
lines changed
  • content/tutorial/03-sveltekit

2 files changed

+3
-1
lines changed

content/tutorial/03-sveltekit/05-forms/01-the-form-element/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export function load({ cookies }) {
4141
};+++
4242
```
4343

44+
The `request` is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object; `await request.formData()` returns a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) instance.
45+
4446
When we hit Enter, the database is updated and the page reloads with the new data.
4547

4648
Notice that we haven't had to write any `fetch` code or anything like that — data updates automatically. And because we're using a `<form>` element, this app would work even if JavaScript was disabled or unavailable.

content/tutorial/03-sveltekit/06-api-routes/02-post-handlers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function POST({ request, cookies }) {
4949
}
5050
```
5151

52-
The `request` is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object; `await request.json()` returns the data that we posted from the event handler.
52+
As with `load` functions and form actions, the `request` is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object; `await request.json()` returns the data that we posted from the event handler.
5353

5454
We're returning a response with a [201 Created](https://httpstatusdogs.com/201-created) status and the `id` of the newly generated todo in our database. Back in the event handler, we can use this to update the page:
5555

0 commit comments

Comments
 (0)