Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nextjs api example

//api/user.js

export default function handler(req, res) {
  if (req.method === 'POST') {
    // Process a POST request - Example:
    res.status(200).json({name: "John Doe" })
  } else {
    // Handle any other HTTP method
  }
}
Source by nextjs.org #
 
PREVIOUS NEXT
Tagged: #nextjs #api
ADD COMMENT
Topic
Name
8+7 =