7.5.1 • Published 3 years ago
tiny-json-http v7.5.1
tiny-json-http
Minimalist HTTP client for GET, POST, PUT, PATCH and DELETE JSON payloads
- Zero dependencies: perfect for AWS Lambda
- Sensible default: assumes buffered JSON responses
- System symmetry: Node style errback API, or Promises for use with Async/Await
npm i tiny-json-http --saveAPI
Read methods
tiny.get(options[, callback])tiny.head(options[, callback])tiny.options(options[, callback])
Write methods
tiny.post(options[, callback])tiny.put(options[, callback])tiny.patch(options[, callback])tiny.del(options[, callback)]
*callback is optional, tiny methods will return a promise if no callback is provided
Options
urlrequireddataform vars fortiny.post,tiny.put,tiny.patch, andtiny.deleteotherwise querystring vars fortiny.getheaderskey/value map used for headers (including support for uploading files withmultipart/form-data)bufferif set totruethe response body is returned as a buffer
Callback values
erra real javascriptErrorif there was onedataan object withheadersandbodykeys
Promises
- if no
callbackis provided to the tiny-json-http methods, a promise is returned - perfect for use of async/await
Examples
With Async / Await
var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'
;(async function _iife() {
try {
console.log(await tiny.get({url}))
} catch (err) {
console.log('ruh roh!', err)
}
})();With Callback
var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'
tiny.get({url}, function _get(err, result) {
if (err) {
console.log('ruh roh!', err)
}
else {
console.log(result)
}
})Check out the tests for more examples! :heart_decoration:
7.5.1
3 years ago
7.5.0
3 years ago
7.4.0
4 years ago
7.4.2
4 years ago
7.4.1
4 years ago
7.3.1
5 years ago
7.3.0
6 years ago
7.2.2
6 years ago
7.2.1
6 years ago
7.2.0
6 years ago
7.1.2
7 years ago
7.1.1
7 years ago
7.1.0
7 years ago
7.0.2
8 years ago
7.0.1
8 years ago
7.0.0
8 years ago
6.2.0
8 years ago
6.0.1
8 years ago
6.0.0
8 years ago
5.3.2
8 years ago
5.3.1
9 years ago
5.3.0
9 years ago
5.2.0
9 years ago
5.1.2
9 years ago
5.1.1
9 years ago
5.1.0
9 years ago
5.0.2
9 years ago
5.0.1
9 years ago
5.0.0
9 years ago
4.2.0
10 years ago
4.1.0
10 years ago
4.0.1
10 years ago
4.0.0
10 years ago
3.0.7
10 years ago
3.0.6
10 years ago
3.0.5
10 years ago
3.0.4
10 years ago
3.0.2
10 years ago
3.0.0
10 years ago
2.0.3
10 years ago
2.0.0
10 years ago
1.0.3
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago