My API routes doesn't work
Unanswered
Ring-necked Duck posted this in #help-forum
Ring-necked DuckOP
Hello 🙂
I'm trying to test my API route with Postman. The structure of my next.js project resembles the one depicted on the right side of this image.
I have a simple route where the file is named hello.js and located in src/pages/api/hello.js. In Postman, I'm attempting to call http://localhost:3000/api/hello.
However, I'm encountering a 404 error. Below is the code in hello.js:
Could you please help me identify what might be causing this 404 error? 🙂
I'm trying to test my API route with Postman. The structure of my next.js project resembles the one depicted on the right side of this image.
I have a simple route where the file is named hello.js and located in src/pages/api/hello.js. In Postman, I'm attempting to call http://localhost:3000/api/hello.
However, I'm encountering a 404 error. Below is the code in hello.js:
export default function handler(req, res) {
res.status(200).json({ message: 'Request successful' });
}
Could you please help me identify what might be causing this 404 error? 🙂
1 Reply
Chinese Egret
Are you sure the port number is correct ?