# ajax-only

> Express middleware for only accept AJAX requests

Latest version **0.0.2** (published 2014-05-15) · 0 weekly downloads

## Install

```sh
npm install ajax-only
pnpm add ajax-only
yarn add ajax-only
bun add ajax-only
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2014-05-15 |
| First published | 2014-05-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | talyssonoc |
| Maintainers | talyssonoc |
| Keywords | express, middleware, ajax, xhr |

## Links

- npm: https://www.npmjs.com/package/ajax-only
- Repository: https://github.com/talyssonoc/express-ajax-only
- Issues: https://github.com/talyssonoc/express-ajax-only/issues
- npm.io page: https://npm.io/package/ajax-only

## Recent versions

- 0.0.2 (latest) — 2014-05-15
- 0.0.1 — 2014-05-11

## README

# ajax-only

Express middleware for only accept AJAX request for a given URL

## Example

```js
	var ajaxOnly = require('ajax-only');
	app.get('/api/*', ajaxOnly([options]));
	app.get('/api/', api.index);
```

## Options

* `redirect`:  URL to where the user will be redirected if using a non-AJAX request (default: false)
* `status`: If using redirect, redirect it with this status. Otherwise, send a response with this status (default: 302 for `redirect`, 404 for `body`)
* `body`: If not using redirect, send a response with this body (default: 'Not found' or the http.STATUS_CODE for the given status)

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