An open API service indexing awesome lists of open source software.

https://github.com/jakecyr/slim-javascript-http-request

Slim Http JavaScript to make GET, DELETE, POST, and PUT requests. An alternative to the larger jQuery library if only the http object is required. Can also be used for Vue.js requests.
https://github.com/jakecyr/slim-javascript-http-request

http javascript vanilla-javascript

Last synced: 11 months ago
JSON representation

Slim Http JavaScript to make GET, DELETE, POST, and PUT requests. An alternative to the larger jQuery library if only the http object is required. Can also be used for Vue.js requests.

Awesome Lists containing this project

README

          

# Slim JavaScript Http Request Library

Slim JavaScript Http Request library to make GET and POST requests. An alternative to the larger jQuery library if only the http object is required. Can also be used with the Vue.js library for HTTP requests.

## Usage

Download the `http.js` file and include it in your project.

### Example `GET ` request:

```javascript
const http = new Http();

http
.get('/names/')
.then(function(res){
console.log(res);
})
.catch(function(err){
console.error(err.error);
})
```

### Example `DELETE ` request:

```javascript
const http = new Http();

http
.delete('/names/?test=deleteMe')
.then(function(res){
console.log(res);
})
.catch(function(err){
console.error(err.error);
})
```

### Example `POST` request:

```javascript
const http = new Http();

http
.post('/names/', { name: 'jake' })
.then(function(res){
console.log(res);
})
.catch(function(err){
console.error(err.status, err.body);
})
```

### Example `PUT` request:

```javascript
const http = new Http();

http
.put('/names/', { name: 'jake' })
.then(function(res){
console.log(res);
})
.catch(function(err){
console.error(err.status, err.body);
})
```