opennode
Advanced tools
Comparing version 1.0.1 to 1.0.3
@@ -20,15 +20,22 @@ { | ||
"keywords": [ | ||
"bitcoin", | ||
"lightning network", | ||
"micotransactions", | ||
"payment processing", | ||
"payment gateway", | ||
"api", | ||
"opennode" | ||
"bitcoin", | ||
"lightning network", | ||
"microtransactions", | ||
"payment processing", | ||
"payment gateway", | ||
"api", | ||
"opennode" | ||
], | ||
"main": "src/lib.js", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"dependencies": { | ||
"axios": "^0.18.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"mocha": "^5.2.0" | ||
}, | ||
"scripts":{ | ||
"test": "mocha" | ||
} | ||
} |
# OpenNode Node.js Library | ||
[![Version](https://img.shields.io/npm/v/opennode.svg)](https://www.npmjs.org/package/opennode) | ||
[![Build Status](https://travis-ci.org/opennodedev/opennode-node.svg?branch=master)](https://travis-ci.org/opennodedev/opennode-node) | ||
[![Try opennode on RunKit](https://badge.runkitcdn.com/opennode.svg)](https://npm.runkit.com/opennode) | ||
@@ -37,3 +39,3 @@ The OpenNode Node library provides convenient access to the OpenNode API from | ||
catch (error) { | ||
console.error(`${error.message}`); | ||
console.error(`${error.status} | ${error.message}`); | ||
} | ||
@@ -58,3 +60,3 @@ ``` | ||
.catch(error => { | ||
console.error(error.message); | ||
console.error(`${error.status} | ${error.message}`); | ||
}); | ||
@@ -61,0 +63,0 @@ ``` |
const axios = require('axios'); | ||
const version = 'npm-opennode-v1.0.0' | ||
const version = 'npm-opennode-v1.0.3' | ||
var instance = undefined; | ||
var api_key; | ||
function setCredentials(api_key = '', environment = 'live') { | ||
function setCredentials(key = '', environment = 'live') { | ||
if (instance != undefined) return; | ||
api_key = key; | ||
instance = axios.create(); | ||
instance.defaults.baseURL = (api_key === 'live') ? 'https://api.opennode.co/v1' : 'https://dev-api.opennode.co/v1'; | ||
instance.defaults.baseURL = (environment === 'live') ? 'https://api.opennode.co/v1' : 'https://dev-api.opennode.co/v1'; | ||
instance.defaults.timeout = 15000; | ||
@@ -73,3 +75,3 @@ instance.defaults.headers = { 'Authorization' : api_key, 'user_agent' : version }; | ||
const response = await instance.get(`/withdrawals`); | ||
return JSON.parse(response.data); | ||
return response.data.data; | ||
@@ -95,3 +97,3 @@ } catch (error) { | ||
const response = await axios.get(`/currencies`); | ||
const response = await instance.get(`/currencies`); | ||
return response.data.data; | ||
@@ -98,0 +100,0 @@ |
6507
98
82
2