Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koa v2: ctx.status initially 404 rather than undefined. #888

Closed
sdd opened this issue Jan 26, 2017 · 4 comments
Closed

koa v2: ctx.status initially 404 rather than undefined. #888

sdd opened this issue Jan 26, 2017 · 4 comments

Comments

@sdd
Copy link

sdd commented Jan 26, 2017

The koa-v2 documentation states that:

By default, response.status is not set unlike node's res.statusCode which defaults to 200.

Yet, it appears to be initially set to 404. If I make a request to the following simple test server:

const app = new Koa();
app.use(ctx => console.log('status: ' + ctx.status));   // or ctx.response.status
const server = app.listen();

I get status: 404 on the console.

@PlasmaPower
Copy link
Contributor

Yes, that's the case. I thought we already fixed the documentation. Oops.

@PlasmaPower
Copy link
Contributor

See #705, but the resolution there is incorrect

@sdd
Copy link
Author

sdd commented Jan 27, 2017

Slightly a shame in my particular case as I wanted ctx.status to be initially undefined, but hey ho, I can live with it 😀

@PlasmaPower
Copy link
Contributor

@sc0ttyd you might try ctx._explicitStatus && ctx.status || undefined, but it's undocumented so it might break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants