A tiny http client for nodejs & browser
$ npm install tinyget --saveOr, via webmodules
$ wpm install tinyget --saveOr, via bower
$ bower install tinyget --savevar tinyget = require('tinyget');var tinyget = window.TinyGet;// default is get
tinyget('/path/file').qry({key: value}).exec(function(err, result) {
// TODO
});
// get, post, put, delete, options
tinyget.post('/path/file').payload({key:'value'}).exec(function(err, result) {
// TODO
});
// alt style 1
tinyget({
url: '/path/file',
payload: {key:'value'}
}).exec(function(err, result) {
// TODO
});
tinyget.post({
url: '/path/file',
contentType: 'application/json',
evalType: 'json',
payload: {key:'value'}
}).exec(function(err, result) {
// TODO
});
// alt style 2
tinyget({
url: '/path/file',
payload: {key:'value'}
}, function(err, result) {
// TODO
});
tinyget.put({
url: '/path/file',
payload: {key:'value'}
}, function(err, result) {
// TODO
});- options : url string or object
- url: remote url(string), required.
- payload: payload (string/object), default is null.
- qry: query string (string/object), default is null.
- contentType: request content-type (string), default when payload is object
application/jsonelsetext/form-url-encoded - responseType: xhr.responseType(xhr2) (string), default is null
- type: response object eval type
text, json, xml(string), default isauto - headers: request headers (object), default is null.
- sync: sync request (boolean), default is false
Licensed under the MIT License. See LICENSE for the full license text.