Skip to content

eightyfive/koa-request-xhr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

koa-request-xhr

This middleware simply sets a xhr boolean on koa's ctx.state namespace.

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.state.xhr) {
    this.body = { message: 'Hello World' };
  } else {
    this.body = 'Hello World';
  }
});

app.listen(3000);

About

Express req.xhr equivalent for Koa

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published