Last active
March 7, 2019 19:00
-
-
Save christroutner/1f5b1d91e182ae4d102c5c1add1889b9 to your computer and use it in GitHub Desktop.
Rate Limit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const axios = require("axios"); | |
//const SERVER = `https://rest.bitcoin.com/v2/`; | |
const SERVER = `http://localhost:3000/v2/`; | |
// Inspect utility used for debugging. | |
const util = require("util"); | |
util.inspect.defaultOptions = { | |
showHidden: true, | |
colors: true, | |
depth: 3 | |
}; | |
async function runTest() { | |
const username = "BITBOX" | |
// Pro-tier is accessed by using the right password. | |
//const password = "BITBOX" | |
const password = "something" | |
const combined = `${username}:${password}` | |
var base64Credential = Buffer.from(combined).toString('base64') | |
var readyCredential = 'Basic '+base64Credential; | |
const options = { | |
method: "GET", | |
url: `${SERVER}control/getInfo`, | |
headers: {'Authorization': readyCredential} | |
}; | |
try { | |
const result = await axios(options); | |
console.log(`result.status: ${result.status}`); | |
console.log(`result.data: ${util.inspect(result.data)}`); | |
} catch (err) { | |
if (err.response && err.response.status) { | |
console.log(`status: ${err.response.status}`) | |
console.log(`Message: ${err.response.statusText}`) | |
} | |
else console.log(`error: `, err); | |
} | |
} | |
runTest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment