Skip to content

Commit

Permalink
Merge pull request #3 from vansergen/defaults
Browse files Browse the repository at this point in the history
Add defaults method
  • Loading branch information
vansergen authored Oct 10, 2019
2 parents c1bb3c6 + eab30d6 commit bfbf47e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
let request = require('request-promise-native');
const request = require('request-promise-native');

class Client {
/**
* @params {Object} [options={}]
*/
constructor({ ...options } = {}) {
request = request.defaults(options);
this.defaults = options;
}

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ class Client {
* @params {Object} options
*/
async request(options) {
return request(options);
return this.defaults(options);
}

/**
Expand All @@ -77,6 +77,14 @@ class Client {
static jar(cookieStore) {
return request.jar(cookieStore);
}

get defaults() {
return request.defaults(this._rpoptions);
}

set defaults(options) {
this._rpoptions = options;
}
}

module.exports = Client;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rpc-request",
"version": "2.0.0",
"version": "2.1.0",
"description": "Simple wrapper of the request-promise-native in a class",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit bfbf47e

Please sign in to comment.