0.0.5 • Published 8 years ago
@slicky/http v0.0.5
Slicky/HTTP
Super simple (but advanced) ajax reactive library. Using RxJS. Supports sending files.
Installation
$ npm install @slicky/httpUsage
import {Http} from '@slicky/http';
const http = new Http;
const data = {number: 5};
const options = {};
http.request('/users', 'GET', data, options).subscribe((response) => {
console.log(response.json());
});Shortcuts
http.get('/api', data, options).subscribe((response) => {});
http.post('/api', data, options).subscribe((response) => {});
http.files('/api', filesList, data, options).subscribe((response) => {});Options
jsonp: name of callback for jsonp requests, whentrueis given callback name is used. Default isfalsejsonPrefix: prefix for json requests. Read more here. Default isnullmimeType: Default isnullheaders: List of headers to be send to server. Default is{}files: List of files to be send to server. Default is[]
Queue
By default all your requests are called from queue one by one, so there is always just one request running (or zero). Inspiration is from this article http://blog.alexmaccaw.com/queuing-ajax-requests.
You can disable this feature with ImmediateQueue:
import {Http, ImmediateQueue} from '@slicky/http';
const http = new Http({
queue: new ImmediateQueue
});Known limitations
- All non ASCII chars (eg. letters with diacritics) in file names are converted to ASCII chars before uploading.