I am creating this api endpoint called pincode.js in Nextjs:
export default function handler(req, res) {
res.status.json([234400, 721302, 110003, 560017]);
}
but it is giving the error : res.status.json() is not a function How to handle this?
CodePudding user response:
status is a function that expects a status code, you should call or omit it.
passing status 200 to it:
export default function handler(req, res) {
res.status(200).json([234400, 721302, 110003, 560017]);
}
omit status code, and send default one (200, if I'm not mistaken):
export default function handler(req, res) {
res.json([234400, 721302, 110003, 560017]);
}