d1fdd2bbf8
* Added descriptions * Added descriptions to API Reference * Added descriptions to API Routes * Added descriptions to basic features * Added descriptions to the routing docs * Update exportPathMap.md Co-authored-by: Joe Haddad <timer150@gmail.com>
525 B
525 B
description |
---|
You can add the dynamic routes used for pages to API Routes too. Learn how it works here. |
Dynamic API Routes
API routes support dynamic routes, and follow the same file naming rules used for pages
.
For example, the API route pages/api/post/[pid].js
has the following code:
export default (req, res) => {
const {
query: { pid },
} = req
res.end(`Post: ${pid}`)
}
Now, a request to /api/post/abc
will respond with the text: Post: abc
.