Skip to content

Instantly share code, notes, and snippets.

@christroutner
Last active March 7, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christroutner/1f5b1d91e182ae4d102c5c1add1889b9 to your computer and use it in GitHub Desktop.
Save christroutner/1f5b1d91e182ae4d102c5c1add1889b9 to your computer and use it in GitHub Desktop.
Rate Limit Test
"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