POST requests are hanging using api routes
Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
I have an endpoint at /api/save-user which should be a POST request. When I use Insomnia to submit a POST to my endpoint, it just hangs. I put a console.log near the top and it doesn't ever get called either. It seems like something is intercepting my request. If I visit http://localhost:3000/api/save-user the requests work just fine! It's obviously a GET when done through the browser. If I change my Insomnia HTTP type to a GET, it also hangs. I don't understand why any requests from Insomnia would cause it to hang. Here is my code.
export default async function handler(req, res) {
console.log("req....", req);
try {
if (req.method === 'POST') {
console.log("request in the POST:", req)
res.status(200).json({ sid: message.sid })
}
} catch (err) {
res.status(500).send({ error: err })
}
}
Any ideas why the above doesn't work?
export default async function handler(req, res) {
console.log("req....", req);
try {
if (req.method === 'POST') {
console.log("request in the POST:", req)
res.status(200).json({ sid: message.sid })
}
} catch (err) {
res.status(500).send({ error: err })
}
}
Any ideas why the above doesn't work?