1.0.1 • Published 9 years ago
koa-request-xhr v1.0.1
koa-request-xhr
This middleware simply sets a xhr
boolean on the koa request.
This aims to be the equivalent of Express req.xhr
Installation
$ npm install koa-request-xhr --save
Example
var koa = require('koa');
var xhr = require('koa-request-xhr');
var app = koa();
app.use(xhr());
app.use(function *(){
if (this.request.xhr) {
this.body = { message: 'Hello World' };
} else {
this.body = 'Hello World';
}
});
app.listen(3000);