koa-request-xhr

1.0.1 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i koa-request-xhr

Weekly Downloads

6

Version

1.0.1

License

ISC

Last publish

Collaborators

  • eightyfive