Skip to content

Commit 5c99344

Browse files
authored
fix(docs): adjust api route documentation examples
1 parent d4fcd03 commit 5c99344

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/03-pages/01-building-your-application/01-routing/07-api-routes.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ The following example sends a JSON response with the status code `200` (`OK`) an
217217
```ts filename="pages/api/hello.ts" switcher
218218
import type { NextApiRequest, NextApiResponse } from 'next'
219219

220-
export default function handler(req: NextApiRequest, res: NextApiResponse) {
220+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
221221
try {
222222
const result = await someAsyncOperation()
223223
res.status(200).json({ result })
@@ -228,7 +228,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
228228
```
229229

230230
```js filename="pages/api/hello.js" switcher
231-
export default function handler(req, res) {
231+
export default async function handler(req, res) {
232232
try {
233233
const result = await someAsyncOperation()
234234
res.status(200).json({ result })
@@ -247,7 +247,7 @@ The following example sends a HTTP response with the status code `200` (`OK`) an
247247
```ts filename="pages/api/hello.ts" switcher
248248
import type { NextApiRequest, NextApiResponse } from 'next'
249249

250-
export default function handler(req: NextApiRequest, res: NextApiResponse) {
250+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
251251
try {
252252
const result = await someAsyncOperation()
253253
res.status(200).send({ result })
@@ -258,7 +258,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
258258
```
259259

260260
```js filename="pages/api/hello.js" switcher
261-
export default function handler(req, res) {
261+
export default async function handler(req, res) {
262262
try {
263263
const result = await someAsyncOperation()
264264
res.status(200).send({ result })
@@ -277,7 +277,7 @@ The following example redirects the client to the `/` path if the form is succes
277277
```ts filename="pages/api/hello.ts" switcher
278278
import type { NextApiRequest, NextApiResponse } from 'next'
279279

280-
export default function handler(req: NextApiRequest, res: NextApiResponse) {
280+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
281281
const { name, message } = req.body
282282

283283
try {
@@ -290,7 +290,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
290290
```
291291

292292
```js filename="pages/api/hello.js" switcher
293-
export default function handler(req, res) {
293+
export default async function handler(req, res) {
294294
const { name, message } = req.body
295295

296296
try {

0 commit comments

Comments
 (0)