API CRUD Route
This is a simple API CRUD route for use with Next.js, using switch
case statements to handle the different HTTP methods.
export default async function handler(req, res) {
switch (req.method) {
case 'PUT':
res.status(201).json({});
break;
case 'DELETE':
res.status(204).json({});
break;
case 'POST':
res.status(200).json({});
break;
case 'GET':
default:
res.status(200).json({});
break;
}
}