Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imbolc/rttp
Tiny and simple lib for rest http requests
https://github.com/imbolc/rttp
ajax api-client
Last synced: about 2 months ago
JSON representation
Tiny and simple lib for rest http requests
- Host: GitHub
- URL: https://github.com/imbolc/rttp
- Owner: imbolc
- Created: 2015-04-25T06:16:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T07:31:26.000Z (almost 8 years ago)
- Last Synced: 2024-07-30T16:51:07.339Z (5 months ago)
- Topics: ajax, api-client
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
rttp
====rttp is a tiny and simple http requests module
Example
-------
rttp.get('/url')
.success(function (data, xhr) { })
.error(function (data, xhr) { });
.finish(function (data, xhr) { });API
---
rttp(method, url, data, config)
rttp.get(url, config)
rttp.post(url, data, config)
rttp.put(url, data, config)
rttp.patch(url, data, config)
rttp.del(url, config)Config options
--------------
- `headers`: [obj], default: `{ 'Content-Type': 'application/json; charset=utf-8' }`
- `dataParser`: function for parsing response data
- `dataDumper`: function for dumping response dataChange defaults
---------------
rttp.setup({
headers: {
// add auth header to each request
Authorization: function () { return 'Bearer ' + localStorage.getItem('auth_token'); },// remove default Content-Type header
'Content-Type': null
},// set default error callback
errorCallback: function (data, xhr) {
alert(xhr.status + ': ' + xhr.statusText);
}// change default data parser
dataParser: function (xhr) { ... },// change default data dumper
dataDumper: function (data) { ... }
});