res.end is not a function
See original GitHub issueBug report
res.end is not a function
Describe the bug
When crating api using API routes, I am getting res.end is not a function.
I created api folder under pages and start.js file inside api folder.
export default function handle(req, res) { console.log(req.body) // The request body console.log(req.query) // The url querystring console.log(req.cookies) // The passed cookies res.end('Hello World') }
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to ‘https://codesandbox.io/embed/hello-world-mi42m’
- Click on ‘…’
- Scroll down to ‘…’
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: [e.g. macOS, Windows]
- Browser (if applies) [e.g. chrome, safari]
- Version of Next.js: [e.g. 9.0.2]
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Nodejs Promise "res.end is not a function" error - Stack Overflow
My code receives list of IDs and processes them making few database calls, that is why I had this "callback hell". Everything worked...
Read more >Express.js res.end() Function - GeeksforGeeks
The res.end() function is used to end the response process. This method actually comes from the Node core, specifically the response.end() ...
Read more >Express.js – res.end() Method - Tutorialspoint
The res.end() method ends the current response process. This method is used to quickly end the response without any data.
Read more >[Solved]-Nodejs Promise "res.end is not a function" error-node.js
You've redefined res with this: processVMDelete(returnedVMIDs) .then(res => {...}) This will hide the higher scoped res associated with the overall request ...
Read more >API Reference - Express 4.x
If not a function, type option is passed directly to the type-is library and this ... verify, This option, if supplied, is called...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had this error when accidentally swapped “request” and “result” sequence in callback function. Please make sure that you have (req, res) instead of (res, req).
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.