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.
- Host: GitHub
- URL: https://github.com/jakecyr/slim-javascript-http-request
- Owner: jakecyr
- Created: 2018-07-17T02:19:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T15:58:34.000Z (about 6 years ago)
- Last Synced: 2025-01-17T09:35:46.124Z (about 1 year ago)
- Topics: http, javascript, vanilla-javascript
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
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);
})
```