提交 4172c894 编写于 作者: D Delba de Oliveira 提交者: Tim Neutkens

Further clarification that api routes should be inside the page… (#7780)

上级 bb2ae41a
......@@ -1047,7 +1047,7 @@ export default withRouter(MyLink)
</ul>
</details>
API routes provides a straightforward solution to build your `API` with `Next.js`. Start by creating the `api` folder inside the `pages` folder. Every file inside `api` is mapped to `/api/*`, for example `api/posts.js` will be mapped to `/api/posts`. Here's how an `api` route looks like:
API routes provides a straightforward solution to build your `API` with `Next.js`. Start by creating the `api` folder inside the `pages` folder. Every file inside `./pages/api` is mapped to `/api/*`, for example `./pages/api/posts.js` will be mapped to `/api/posts`. Here's how an `api` route looks like:
```js
export default (req, res) => {
......@@ -1062,7 +1062,7 @@ export default (req, res) => {
#### Dynamic routes support
API pages support [dynamic routing](#dynamic-routing), so you can use all benefits mentioned already above.
Consider the following page `pages/api/post/[pid].js`, here is how you get parameters inside the resolver method:
Consider the following page `./pages/api/post/[pid].js`, here is how you get parameters inside the resolver method:
```js
export default (req, res) => {
const {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册