# koa-isajax

> Middleware for koajs 2 to check if the incoming request is an Ajax request.

Latest version **1.0.5** (published 2016-12-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install koa-isajax
pnpm add koa-isajax
yarn add koa-isajax
bun add koa-isajax
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-12-18 |
| First published | 2016-12-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Bernat Jufré |
| Maintainers | behind-design |
| Keywords | koa, koajs, middleware, ajax, xhr, request |

## Links

- npm: https://www.npmjs.com/package/koa-isajax
- Repository: https://github.com/behind-design/koa-isajax
- Homepage: https://github.com/behind-design/koa-isajax#readme
- Issues: https://github.com/behind-design/koa-isajax/issues
- npm.io page: https://npm.io/package/koa-isajax

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2016-12-18
- 1.0.4 — 2016-12-18
- 1.0.3 — 2016-12-18
- 1.0.2 — 2016-12-18
- 1.0.1 — 2016-12-18
- 1.0.0 — 2016-12-18

## README

# koa-isajax

Express `req.xhr` equivalent for Koa 2 applications.
Middleware for Koa 2 that sets a boolean on the `ctx.state` on whether or not the request is and Ajax request.

This middleware is the equivalent to [Express `req.xhr`.](http://expressjs.com/en/api.html#req.xhr)

## Installation
`$ npm install koa-isajax --save`

## Example

```javascript
import Koa from 'koa';
import isajax from 'koa-isajax';

const app = new Koa();

app.use(isajax());
app.use(async (ctx) => {
    if (ctx.state.xhr) {
        // Ajax request.
    } else  {
        // Not ajax request.
    }
});

app.listen(3000);
```

---
_Source: https://npm.io/package/koa-isajax · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
