0

I am using bitcore explorer and I want to initialize insight api in testnet. It has the following code. I try var insight = new Insight('testnet') but it is not working. What value for url should i input so that Networks.get(url) === testnet

function Insight(url, network) {
  if (!url && !network) {
    return new Insight(Networks.defaultNetwork);
  }
  if (Networks.get(url)) {
    network = Networks.get(url);
    if (network === Networks.livenet) {
      url = 'https://insight.bitpay.com';
    } else {
      url = 'https://test-insight.bitpay.com';
    }
  }
  JSUtil.defineImmutable(this, {
    url: url,
    network: Networks.get(network) || Networks.defaultNetwork
  });
  this.request = request;
  return this;
}
-1

Try this

const bitcore = require("bitcore-lib");
const Insight = require("bitcore-explorers").Insight;
insight = new Insight(bitcore.Networks.testnet);

then do the rest.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.