Skip to content

Commit

Permalink
disambiguate this.api_key and fix for string-based instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
doersf committed Jun 10, 2021
1 parent c7b2c8b commit 081caf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/block_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ function BlockIo (config, pin, version, options) {

if (typeof(config) === 'string') {

this.key = config;
this.api_key = config;
this.version = version || BlockIo.DEFAULT_VERSION;
this.server = BlockIo.DEFAULT_SERVER;
this.port = BlockIo.DEFAULT_PORT;
this.keys = {}; // we will store keys for use in between calls here

if (pin) {
this.pin = pin;
Expand All @@ -30,7 +31,7 @@ function BlockIo (config, pin, version, options) {
if (options && typeof(options) == 'object') this._cloneOptions(options);

} else if (config && typeof(config) == 'object') {
this.key = config.api_key;
this.api_key = config.api_key;
this.version = config.version || BlockIo.DEFAULT_VERSION;
this.server = config.server || BlockIo.DEFAULT_SERVER;
this.port = config.port || BlockIo.DEFAULT_PORT;
Expand Down Expand Up @@ -439,7 +440,7 @@ BlockIo.prototype._constructURL = function (path, query) {
};

BlockIo.prototype._request = function (path, args, cb) {
const url = this._constructURL(path, {api_key: this.key});
const url = this._constructURL(path, {api_key: this.api_key});
const method = BlockIo.decideRequestMethod(args);

const promise = new Promise((f,r) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dogecoin",
"wallet"
],
"version": "4.0.1",
"version": "4.0.2",
"preferGlobal": false,
"homepage": "https://github.com/BlockIo/block_io-nodejs",
"author": "Patrick Lodder <[email protected]> (https://github.com/patricklodder)",
Expand Down

0 comments on commit 081caf2

Please sign in to comment.