moirai | React | Game Engine library
kandi X-RAY | moirai Summary
kandi X-RAY | moirai Summary
React.js game engine. Exciting, experimental and unstable. moirai borrows a lot of ideas from Lyria.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- returns true if dir is a directory
moirai Key Features
moirai Examples and Code Snippets
Community Discussions
Trending Discussions on moirai
QUESTION
I've been frustrated with this issue for more than 24 hours and I've narrowed down the issue to this:
In the following code, I'm updating a MongoDB document using mongoose and upon a successful update, I return a json object via an express response. I get the following error when I try to call a response in the in the callback from the mongoose.
The update is successful in the database, I get the data back from the callback, and everything works as it should, except for sending the response saying everything is great.
I do not send a responses before this nor do I touch the res
object in any way prior to sending. I am seeking help on how to send a response upon successful callback.
Error:
...ANSWER
Answered 2017-Feb-08 at 22:44Ok, so in the Error message printed out we find: Can't set headers after they're sent.
In your express route, you've written res.json({});
twice. You appear to be receiving proper data back from the mongoose method. You then call res.json({message: 'gives error'});
. This happens, as you say, event when called next(), because you are explicitly telling it to. Write an if-else
statement where you've currently written that, to handle the error, like so:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install moirai
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page