Compare commits

...

7 Commits

Author SHA1 Message Date
acebe6a381 1.1.42 2019-10-28 16:18:15 +01:00
7031504852 1.1.41 2019-10-27 14:41:49 +01:00
3010a1da9a fix(core): update 2019-10-27 14:41:48 +01:00
cdead33be4 1.1.40 2019-10-27 14:39:07 +01:00
5e23649702 fix(core): update 2019-10-27 14:39:06 +01:00
cc6bd5726a 1.1.39 2019-10-27 14:38:13 +01:00
f487584e80 fix(core): update 2019-10-27 14:38:12 +01:00
3 changed files with 12 additions and 10 deletions

View File

@ -33,8 +33,9 @@ Use TypeScript for best in class instellisense.
* continuously updated * continuously updated
* uses node native http and https modules * uses node native http and https modules
* used in modules like @pushrocks/smartproxy and @apiglobal/typedrequest * used in modules like @pushrocks/smartproxy and @apiglobal/typedrequest
* commercial support available at [https://lossless.support](https://lossless.support)
> note: smartrequest uses the **native** node request module under the hood (not the one from npm) > note: smartrequest uses the **native** node http/https modules under the hood (not the bloated one from npm)
```javascript ```javascript
import * as smartrequest from 'smartrequest' import * as smartrequest from 'smartrequest'
@ -45,23 +46,24 @@ let options: smartrequest.ISmartRequestOptions = { // typed options
"Content-Type": "application/json" "Content-Type": "application/json"
"Authorization": "Bearer token" "Authorization": "Bearer token"
}, },
requestBody: { requestBody: JSON.stringify({
key1: 'value1', key1: 'value1',
key2: 3 key2: 3
} })
} }
smartrequest.post('https://example.com', options).then(res => { smartrequest.request('https://example.com', options).then(res => {
console.log(res.status) console.log(res.status)
console.log(res.body) // if json, body will be parsed automatically console.log(res.body) // if json, body will be parsed automatically
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
// also available // dedicated JSON metods are available:
smartrequest.get(...) smartrequest.getJson(...)
smartrequest.put(...) smartrequest.postJson(...)
smartrequest.del(...) smartrequest.putJson(...)
smartrequest.delJson(...)
// streaming // streaming
smartrequest.get('https://example.com/bigfile.mp4', optionsArg, true).then(res => { // third arg = true signals streaming smartrequest.get('https://example.com/bigfile.mp4', optionsArg, true).then(res => { // third arg = true signals streaming

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartrequest", "name": "@pushrocks/smartrequest",
"version": "1.1.38", "version": "1.1.42",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartrequest", "name": "@pushrocks/smartrequest",
"version": "1.1.38", "version": "1.1.42",
"private": false, "private": false,
"description": "dropin replacement for request", "description": "dropin replacement for request",
"main": "dist/index.js", "main": "dist/index.js",