How to transfer values between two middleware
test.post('/', koaBody, function* (next) {
var body = this.request.body;
console.log(body);
yield body;
yield next;
})
app.use(function* (next) {
this.body="sucessful";
Log ("middleware 2");
yield this.mongo.db('app_info').collection('platform').insert({"xiaoming":"xiaoming1"});
this.body= this.mongo.db('app_info').collection('platform').findOne();
});
As above, I want to transfer the body obtained from post of the first middleware to the second middleware, and then the second middleware will store it into monodb. How can I get it?
Global variable value transfer