# greenajax

> make your work easy in ajax

Latest version **1.1.2** (published 2022-11-13) · MIT license · 0 weekly downloads

## Install

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

## 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.1.2 |
| Published | 2022-11-13 |
| First published | 2022-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sagharizadeh |
| Maintainers | sagharizadeh |
| Keywords | ajax, front-end |

## Links

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

## Recent versions

- 1.1.2 (latest) — 2022-11-13
- 1.1.1 — 2022-11-13
- 1.1.0 — 2022-11-13
- 1.0.3 — 2022-11-13
- 1.0.2 — 2022-10-16
- 1.0.1 — 2022-10-10

## README

# GreenAjax

![logo](logo.png)

## About

This is a low volume library that makes your work easy in ajax.
Note: This is just for front-end!

## Installation

```
npm install greenajax
```

Or from CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/greenajax@1.1.2/dist/greenajax.min.js"></script>
```

## Usage

### GET request
```js
greenajax({
	method: 'get',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});
```

### POST request
```js
greenajax({
	method: 'post',
	url: 'http://localhost:3000/api',
	body: {
		id: 101,
		title: 'foo',
		body: 'bar',
		user: 1
	}
}, json => {
	console.log(json);
});
```

### PUT request
```js
greenajax({
	method: 'put',
	url: 'http://localhost:3000/api',
	body: {
		id: 1,
		title: 'foo',
		body: 'bar',
		user: 1
	}
}, json => {
	console.log(json);
});
```

### PATCH request
```js
greenajax({
	method: 'patch',
	url: 'http://localhost:3000/api',
	body: {
		title: 'foo'
	}
}, json => {
	console.log(json);
});
```

### DELETE request
```js
greenajax({
	method: 'delete',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});
```

### HEAD request
```js
greenajax({
	method: 'head',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});
```

You can also edit fetch options:

```js
greenajax({
	method: 'get',
	url: 'http://localhost:3000/api',
	mode: 'cors', // 'cors', 'no-cors' or 'same-origin'
	credentials: 'same-origin', // 'same-origin', 'omit' or 'include'
	cache: 'default', // 'default', 'no-store', 'reload', 'no-cache', 'force-cache' or 'only-if-cached'
	redirect: 'follow', // 'follow', 'error' or 'manual'
	referrer: 'about:client',
	referrerPolicy: 'no-referrer', // 'no-referrer', 'no-referrer-when-downgrade', 'same-origin', 'origin', 'strict-origin', 'origin-when-cross-origin', 'strict-origin-when-cross-origin' or 'unsafe-url'
	headers: {
		'Content-Type' : 'application/json'
	}
}, json => {
	console.log(json);
});
```

## History

[Releases](https://github.com/sagharizadeh/greenajax/releases)

## License

[MIT License](https://github.com/sagharizadeh/greenajax/blob/main/LICENSE) © Muhammad Hussain Saghari Zadeh

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