Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bolajiayodeji/simple-ajax-library
A simple AJAX Library for making HTTP Requests
https://github.com/bolajiayodeji/simple-ajax-library
ajax ajax-request http library
Last synced: 3 months ago
JSON representation
A simple AJAX Library for making HTTP Requests
- Host: GitHub
- URL: https://github.com/bolajiayodeji/simple-ajax-library
- Owner: BolajiAyodeji
- License: mit
- Created: 2019-04-05T12:03:23.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T09:19:18.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T01:48:55.099Z (8 months ago)
- Topics: ajax, ajax-request, http, library
- Language: JavaScript
- Homepage: https://bolajiayodeji.github.io/simple-ajax-library/
- Size: 2.06 MB
- Stars: 16
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Getting Started
Download and include the JavaScript file | [full version](https://github.com/BolajiAyodeji/simple-ajax-library/blob/master/dist/simpleAjax.js) | [minified](https://github.com/BolajiAyodeji/simple-ajax-library/blob/master/dist/simpleAjax.min.js) | [ES6 version](https://github.com/BolajiAyodeji/simple-ajax-library/blob/master/src/simpleAjax.js) |
```html
```
```html```
Create a new simpleAjax
```js
const http = new simpleAJAX;
```# Examples
* GET Request
```js
users = http.get('https://jsonplaceholder.typicode.com/users',
(err, users) => {
if(err) {
console.log(err)
} else {
console.log(users);
}
});
```* POST Request
```js
const data = {
"name": "Bolaji Ayodeji",
"username": "bolajiayodeji",
"email": "[email protected]",
"address": {
"street": "Hello world",
"suite": "Hello",
"city": "Lokoja, Kogi",
"zipcode": "xxx-xxx-xxx",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "+234 8109445504",
"website": "https://bolajiayodeji.com",
"company": {
"name": "PhilanthroLab",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
};http.post('https://jsonplaceholder.typicode.com/users',
data, (err, user) => {
if(err) {
console.log(err)
} else {
console.log(user);
}
});
```* PUT Request
```js
const data = {
"name": "Bolaji Ayodeji",
"username": "bolajiayodeji",
"email": "[email protected]",
"address": {
"street": "Hello world",
"suite": "Hello",
"city": "Lokoja, Kogi",
"zipcode": "xxx-xxx-xxx",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "+234 8109445504",
"website": "https://bolajiayodeji.com",
"company": {
"name": "PhilanthroLab",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
};http.put('https://jsonplaceholder.typicode.com/users/1',
data, (err, user) => {
if(err) {
console.log(err)
} else {
console.log(user);
}
});
```* DELETE Request
```js
users = http.delete('https://jsonplaceholder.typicode.com/users/1',
(err, response) => {
if(err) {
console.log(err)
} else {
console.log(response);
}
});
```# Demo
Demo [here](https://bolajiayodeji.github.io/simple-ajax-library/demo/)# Contribution Guide
```bash
git clone https://github.com/BolajiAyodeji/simple-ajax-library.git
```
```bash
cd simple-ajax-library
```
```bash
npm install
```
```bash
npm run build
```