I have a koa
app which has a bunch of functions split up into separate files. When one route is called I need to pass the context this
to another function (which is also a route) in an separate file.
File a.js
route - http://127.0.0.1:3000/foo
exports.foo = function *() {
this.body = 'Some Value';
}
File b.js
route - http://127.0.0.1:3000/bar
var a = require('a');
exports.bar = function *() {
this.body = yield a.foo(); // this obviously doesn't work.
}
I want to be able to yield a.foo()
with the current context (this
) and have it operate like it is being called by the normal router.