Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Added provider to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
domschiener committed Jan 9, 2017
1 parent f7473dc commit 80ebf4e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ It should be noted that this is a temporary home for the official documentation.

## Getting Started

After you've successfully installed the library, it is fairly easy to get started by simply launching a new instance of the IOTA object. When instantiating the object you have the option to decide the `host` and `port` that are used for sending the requests to, as can be seen in the example below:
After you've successfully installed the library, it is fairly easy to get started by simply launching a new instance of the IOTA object. When instantiating the object you have the option to decide the API provider that is used to send the reuqests to. You can either supply this directly via the `provider` option, or individually with `host` and `port`, as can be seen in the example below:

```
// Create IOTA instance
// Create IOTA instance with host and port as provider
var iota = new IOTA({
'host': 'http://localhost',
'port': 14265
});
// Create IOTA instance directly with provider
var iota = new IOTA({
'provider': 'http://api.iotatoken.com' // this is just an example
});
// now you can start using all of the functions
iota.api.getNodeInfo();
```
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iota.lib.js",
"version": "0.0.17",
"version": "0.0.18",
"description": "Javascript Library for the IOTA API.",
"main": "./dist/iota.js",
"authors": [
Expand Down
4 changes: 2 additions & 2 deletions dist/iota.js
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,7 @@ function IOTA(settings) {
settings = settings || {};
this.host = settings.host ? settings.host : "http://localhost";
this.port = settings.port ? settings.port : 14265;
this.provider = this.host + ":" + this.port;
this.provider = settings.provider || this.host + ":" + this.port;

this._makeRequest = new makeRequest(this.provider);
this.api = new api(this._makeRequest);
Expand All @@ -2743,7 +2743,7 @@ IOTA.prototype.changeNode = function(settings) {
settings = settings || {};
this.host = settings.host ? settings.host : "http://localhost";
this.port = settings.port ? settings.port : 14265;
this.provider = this.host + ":" + this.port;
this.provider = settings.provider || this.host + ":" + this.port;

this._makeRequest.setProvider(this.provider);
};
Expand Down
6 changes: 3 additions & 3 deletions dist/iota.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/iota.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function IOTA(settings) {
settings = settings || {};
this.host = settings.host ? settings.host : "http://localhost";
this.port = settings.port ? settings.port : 14265;
this.provider = this.host + ":" + this.port;
this.provider = settings.provider || this.host + ":" + this.port;

this._makeRequest = new makeRequest(this.provider);
this.api = new api(this._makeRequest);
Expand All @@ -34,7 +34,7 @@ IOTA.prototype.changeNode = function(settings) {
settings = settings || {};
this.host = settings.host ? settings.host : "http://localhost";
this.port = settings.port ? settings.port : 14265;
this.provider = this.host + ":" + this.port;
this.provider = settings.provider || this.host + ":" + this.port;

this._makeRequest.setProvider(this.provider);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iota.lib.js",
"version": "0.0.17",
"version": "0.0.18",
"description": "Javascript Library for the IOTA API.",
"main": "./lib/iota.js",
"scripts": {
Expand Down

0 comments on commit 80ebf4e

Please sign in to comment.