# neocajax

> neocajax is an extremely lightweight alternative to axios, with native typescript support.

Latest version **2.0.9** (published 2020-01-05) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install neocajax
pnpm add neocajax
yarn add neocajax
bun add neocajax
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.9 |
| Published | 2020-01-05 |
| First published | 2020-01-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 103.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | InteraApps |
| Maintainers | keimeno |
| Keywords | Ajax, Cajax, Promise, ClassedAjax |

## Links

- npm: https://www.npmjs.com/package/neocajax
- Repository: https://github.com/keimeno/neocajax
- Homepage: https://github.com/keimeno/neocajax#readme
- Issues: https://github.com/keimeno/neocajax/issues
- npm.io page: https://npm.io/package/neocajax

## Dependencies (2)

- [unfetch](https://npm.io/package/unfetch.md) ^4.1.0
- [@types/node-fetch](https://npm.io/package/@types/node-fetch.md) ^2.5.4

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 2.0.9 (latest) — 2020-01-05
- 2.0.8 — 2020-01-05
- 2.0.7 — 2020-01-05
- 2.0.6 — 2020-01-05
- 2.0.5 — 2020-01-05
- 2.0.4 — 2020-01-05
- 2.0.3 — 2020-01-05
- 2.0.2 — 2020-01-05
- 2.0.1 — 2020-01-05
- 2.0.0 — 2020-01-05

## README

# neocajax v2

## Description

neocajax is an extremely lightweight alternative to axios, with native typescript support.

## Setup

### npm

```bash
npm install neocajax --save
```

### cdn

```html
<script
	src="https://cdn.jsdelivr.net/npm/neocajax@latest/dist/neocajax.min.js"
	type="text/javascript"
></script>
```

## Documentation

To import in the module do:

```javascript
import NeoCajax from 'neocajax';
```

With typescript you can as well import the different types

```typescript
import NeoCajax, { NeoCajaxResponse, NeoCajaxError } from 'neocajax';
```

This will give you a new NeoCajax instance, without any preset options.

If you want to predefine the baseUrl or headers you can create a new instance from this object, with the create() method.

```javascript
neocajax = NeoCajax.create({
	baseUrl: 'https://example.org/',
	headers: {
		Authorization: 'Bearer mytoken'
	}
});
```

To send out a basic get request, one method to do it, is:

```javascript
NeoCajax.get(url, options)
	.then(response => {
		console.log(response.data);
	})
	.catch(error => {
		console.log(error.message);
		console.log(error.response.data);
	});
```

You can also use async/await, because it returns a Promise.

```javascript
const response = await NeoCajax.get(url, options);
```

This works similarly in typescript:

```typescript
NeoCajax.get(url, options)
	.then((response: NeoCajaxResponse) => {
		console.log(response.data);
	})
	.catch((error: NeoCajaxError) => {
		console.log(error.message);
		console.log(error.message.data);
	});
```

And with async/await it looks like the following:

```typescript
const response: NeoCajaxResponse = await NeoCajax.get(url, options);
```

A post request looks similar, just with the difference, that you can pass data with it.

```javascript
const response = await NeoCajax.post(url, data, options);
```

The supported request types currently are:

-   GET
-   POST
-   PUT
-   DELETE

## Contribute

If you want to contribute to this project please make sure to read our guidelines.

-   You need to use tabs as indentation.
-   Explain your changes in the description of your pull request.

Other than that, feel free to support neocajax!

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