Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CRUD with Next.js API routes or vercel/micro. https://stackoverflow.com/q/256349
export default async function handler(req, res) {
if (req.method === 'POST') {
// Create
res.status(201).json({})
}
if (req.method === 'GET') {
// Read
res.status(200).json({})
}
if (req.method === 'PUT') {
// Update
res.status(200).json({})
}
if (req.method === 'DELETE') {
// Delete
res.status(204).json({})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment