Skip to content

Instantly share code, notes, and snippets.

@gfxargentina
Created March 16, 2023 00:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
api nextjs
//controlador
import signCloudinary from '../sign-cloudinary';
export default function handler(req, res) {
//type of request
const { method } = req;
switch (method) {
case 'GET':
res.status(200).json({ msg: 'GET Request' });
break;
case 'POST':
signCloudinary(req, res);
break;
case 'PUT':
res.status(200).json({ msg: 'PUT Request' });
break;
case 'DELETE':
res.status(200).json({ msg: 'DELETE Request' });
break;
default:
res.setHeader('Allow', ['GET', 'POST', 'PUT', 'DELETE']);
res.status(405).end(`Method ${method} Not Allowed`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment