Browse Source

v1.6.1: userAgent and docs

json-url-form v1.6.1
AJ ONeal 4 years ago
parent
commit
3574e35635
  1. 35
      EXTRA.md
  2. 2
      examples/postbin.js
  3. 4
      index.js
  4. 2
      package.json

35
EXTRA.md

@ -0,0 +1,35 @@
# Extra
There are some niche features of @root/request which are beyond the request.js
compatibility.
## userAgent
There's a default User-Agent string describing the version of @root/request, node.js, and the OS.
Add to the default User-Agent
```js
request({
// ...
userAgent: 'my-package/1.0' // add to agent
});
```
Replace the default User-Agent
```js
request({
// ...
headers: { 'User-Agent': 'replace/0.0' }
});
```
Disable the default User-Agent:
```js
request({
// ...
headers: { 'User-Agent': false }
});
```

2
examples/postbin.js

@ -5,7 +5,7 @@ request({
url: 'https://postb.in/1588134650162-6019286897499?hello=world'
//headers: { 'user-agent': false } // remove
//headers: { 'user-agent': 'test/1.0' } // overwrite
//userAgent: 'test/1.1' // not presently implemented
//userAgent: 'test/1.1' // add to the default
})
.then(function(resp) {
console.log(resp.body);

4
index.js

@ -582,8 +582,8 @@ module.exports._keys = Object.keys(_defaults).concat([
'form',
'auth',
'formData',
'FormData'
//'userAgent'
'FormData',
'userAgent' // non-standard for request.js
]);
module.exports.debug =
-1 !== (process.env.NODE_DEBUG || '').split(/\s+/g).indexOf('urequest');

2
package.json

@ -1,6 +1,6 @@
{
"name": "@root/request",
"version": "1.6.0",
"version": "1.6.1",
"description": "A lightweight, zero-dependency drop-in replacement for request",
"main": "index.js",
"files": [

Loading…
Cancel
Save