From 29b2f79ca873ccbc748d114bff3c6758b5f4416e Mon Sep 17 00:00:00 2001 From: Daniel Kelly Date: Mon, 17 Oct 2022 17:14:34 -0500 Subject: [PATCH] remove deprecated useBody, replace with readBody --- docs/content/2.guide/2.directory-structure/1.server.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/2.guide/2.directory-structure/1.server.md b/docs/content/2.guide/2.directory-structure/1.server.md index 8503aa043f9..e4a7d1c6ae2 100644 --- a/docs/content/2.guide/2.directory-structure/1.server.md +++ b/docs/content/2.guide/2.directory-structure/1.server.md @@ -141,7 +141,7 @@ export default defineEventHandler(() => `Default api handler`) ```ts [server/api/submit.post.ts] export default defineEventHandler(async (event) => { - const body = await useBody(event) + const body = await readBody(event) return { body } }) ``` @@ -149,7 +149,7 @@ export default defineEventHandler(async (event) => { You can now universally call this API using `$fetch('/api/submit', { method: 'post', body: { test: 123 } })`. ::alert{type=warning title=Attention} -We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `useBody` within a GET request, `useBody` will throw a `405 Method Not Allowed` HTTP error. +We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `readBody` within a GET request, `readBody` will throw a `405 Method Not Allowed` HTTP error. :: ### Handling Requests With Query Parameters @@ -275,7 +275,7 @@ Create a new file in `server/api/test.post.ts`: ```ts [server/api/test.post.ts] export default defineEventHandler(async (event) => { - const body = await useBody(event) + const body = await readBody(event) await useStorage().setItem('redis:test', body) return 'Data is set' })