Created
March 16, 2023 00:46
-
-
Save gfxargentina/caedb26f04e6bae3b70fab756db43a7c to your computer and use it in GitHub Desktop.
api nextjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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