Skip to content

Tag: koa

How to make koa ctx.throw() use application/json rather than text/plain

I have made a custom error handler for my koa app which works beautifully (except for one sticking point) – using ctx.throw() means any stacktrace is emitted to the server logs and also any custom error message is sent in the response. The one problem is that Content-Type header is text/plain but I really need it to be application/json. app.js:

How to run Generator Functions in Parallel?

Assuming I have a Koa web server with an endpoint like this: Now the client will get the respond after ALL the actions are performed obviously. but the things is each action is dependent on the completion of the previous. Is there a way to execute them in parallel? Note: Turning them to Promises is not an option, unless I