A JavaScript API Wrapper for interacting with a rise node. The library works both in the browser and Node.js.
All available methods are available in the API reference at https://risevision.github.io/rise-ts
Install via your favorite package manager
npm install --save risejs
# or using yarn
yarn add risejs
Include in your javascript
var rise = require('risejs').rise;
// or using es6
import { rise } from 'risejs'
Include via the unpkg CDN in your html
<script type="text/javascript" src="https://unpkg.com/risejs/dist/browser/index.js"></script>
rise
is now globally available on the window
object
<script>
rise.nodeAddress = 'http://example.com:5566';
// ...
</script>
Set the node address on the RiseAPI
object (note: omit any trailing slashes to the url)
rise.nodeAddress = 'http://localhost:5566';
To see other configuration options refer to the API reference
All API method responses can be handled with either a callback or a Promise. For example, to get the chain status using callbacks
rise.blocks.getStatus(function(err, res) {
if (err) {
return console.log('Error: ', err); // handle error
}
console.log(res); // { success: true, broadHash: "12aebd7b...
});
using Promises
rise.blocks.getStatus()
.then(function(res) {
console.log(res); // { success: true, broadHash: "12aebd7b...
})
.catch(function(err) {
console.log('Error: ', err); // handle error
});
using async / await
try {
const res = await rise.blocks.getStatus()
console.log(res) // { success: true, broadHash: "12aebd7b...
}
catch(err) {
console.log('Error: ', err) // handle error
}
If rise.errorAsResponse
is set to true
(the default), application errors will be returned as an object in the response
{
"success": false,
"error": "Message"
}
So that handling errors is as follows
rise.blocks.getStatus()
.then(function(res) {
if (!res.success) {
return console.log('Application Error: ', res.error); // handle Application Error
}
console.log(res); // { success: true, broadHash: "12aebd7b...
})
.catch(function(err) {
console.log('HTTP Error: ', err); // handle HTTP error
});
Our Libraries are written in typescript so that you can use types in your applications
import { rise, BlockStatusResponse } from 'risejs';
function handleStatus(err: Error, status: BlockStatusResponse) {
console.log(status);
};
rise.blocks.getStatus(handleStatus);
All available types are available in the API reference as well at http://risevision.github.io/rise-ts
Additional APIWrapper
objects can be made using the newWrapper
method
var node1 = rise.newWrapper('http://node1:1234');
var node2 = rise.newWrapper('http://node2:1234', { timeout: 5000 });
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
Node >= 4.x is fully supported :)
Read the Contributing Guide for guidelines as well as local development instructions. And thank you to all of our contributors.
Feel free to join the Slack!