Unverified Commit 0549a466 authored by Abir Taheer's avatar Abir Taheer Committed by GitHub

Update TypeScript API Route example (#44517)

The existing example causes issues with eslint's `eslintimport/no-anonymous-default-export` rule that come pre-enabled with `create-next-app`.

Added a name to the api handler function before setting it as the default export.



## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Co-authored-by: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
parent 08fb7b5b
......@@ -103,7 +103,7 @@ The following is an example of how to use the built-in types for API routes:
```ts
import type { NextApiRequest, NextApiResponse } from 'next'
export default (req: NextApiRequest, res: NextApiResponse) => {
export default function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ name: 'John Doe' })
}
```
......@@ -117,7 +117,10 @@ type Data = {
name: string
}
export default (req: NextApiRequest, res: NextApiResponse<Data>) => {
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment