New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

greenajax

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

greenajax

make your work easy in ajax

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

GreenAjax

logo

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:

<script src="https://cdn.jsdelivr.net/npm/greenajax@1.1.2/dist/greenajax.min.js"></script>

Usage

GET request

greenajax({
	method: 'get',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});

POST request

greenajax({
	method: 'post',
	url: 'http://localhost:3000/api',
	body: {
		id: 101,
		title: 'foo',
		body: 'bar',
		user: 1
	}
}, json => {
	console.log(json);
});

PUT request

greenajax({
	method: 'put',
	url: 'http://localhost:3000/api',
	body: {
		id: 1,
		title: 'foo',
		body: 'bar',
		user: 1
	}
}, json => {
	console.log(json);
});

PATCH request

greenajax({
	method: 'patch',
	url: 'http://localhost:3000/api',
	body: {
		title: 'foo'
	}
}, json => {
	console.log(json);
});

DELETE request

greenajax({
	method: 'delete',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});

HEAD request

greenajax({
	method: 'head',
	url: 'http://localhost:3000/api'
}, json => {
	console.log(json);
});

You can also edit fetch options:

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

License

MIT License © Muhammad Hussain Saghari Zadeh

Keywords

ajax

FAQs

Package last updated on 13 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts