Answer the question
In order to leave comments, you need to log in
Question about koa. What do we have next?
I had no experience with Express, maybe that's why the simple moment is incomprehensible.
In a simple koa application example, we pass a generator with the next parameter, which is then yielded inside the application. What is it for?
app.use(function* (next) {
if (this.request.path === '/') {
this.response.body = 'hello world';
} else {
yield next;
}
});
Answer the question
In order to leave comments, you need to log in
Yes, right. The middleware must either end the request or call the next one.
app.use(function* (next) {
if (this.request.path === '/') {
this.response.body = 'hello world';
} else {
//yield next;
}
});
app.use(function* (next) {
this.response.body = 'hello world not from root';
yield next;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question