Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active July 15, 2021 12:44
Show Gist options
  • Save codeBelt/8abb26bda956ac9ec43ee1fc8227216b to your computer and use it in GitHub Desktop.
Save codeBelt/8abb26bda956ac9ec43ee1fc8227216b to your computer and use it in GitHub Desktop.
import nextConnect from 'next-connect';
const apiRoute = nextConnect({
// Handle any other HTTP method
onNoMatch(req, res) {
res.status(405).json({ error: `Method '${req.method}' Not Allowed` });
},
});
// Process a POST request
apiRoute.post((req, res) => {
res.status(200).json({ data: 'success' });
});
export default apiRoute;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment