Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

next js get query parameters

// For example for URL: {__APP_URL__}/api/device/10001?q=hello
// The API route pages/api/device/[device_id].js has the following code:

export default function handler(req, res) { 
  res.status(200).json(req.query) // {"q":"hello","device_id":"10001"}
}
Source by nextjs.org #
 
PREVIOUS NEXT
Tagged: #js #query #parameters
ADD COMMENT
Topic
Name
2+3 =