You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have so far been unable to sort out this issue. I have a code that uses the MongoDb driver and whenever a do a fetch operation, i can no longer write to .response.body, e.g:
Once I call - await users.findOne({ email: req.email }) , I get an error when I do ctx.response.body.
As a workaround, is there a way i can force write the response, or a flag i can use to force oak not to close the response until i explicitly tell it to?
The error I get: The response is not writable.
The text was updated successfully, but these errors were encountered:
#148 seems to be reasonably well described - care is needed when using async await to make sure subsequent middleware aren’t executed before your promise resolves (including Oak’s default response if none is supplied).
As @cmorten says, a more complete code example would be needed to help, but this usually occurs when middleware is not holding onto the request in a way that indicates it is still processing, specifically not invoking or returning the next(). When the middleware "chain" is dropped, oak assumes the body is set synchronously and sends the response.
I have so far been unable to sort out this issue. I have a code that uses the MongoDb driver and whenever a do a fetch operation, i can no longer write to .response.body, e.g:
Once I call -
await users.findOne({ email: req.email })
, I get an error when I doctx.response.body
.As a workaround, is there a way i can force write the response, or a flag i can use to force oak not to close the response until i explicitly tell it to?
The error I get:
The response is not writable.
The text was updated successfully, but these errors were encountered: