Search code examples
node.jsexpresscoinbase-api

coinbase API issue


I'm trying to connect to Coinbase API, using node v12.16.3 with:

var express = require('express');
var router = express.Router();
var Client = require('coinbase').Client;
....
router.get('/', function(req, res, next) {
var client = new Client({
    apiKey: 'my_apiKey',
    apiSecret: 'my_apiSecret'
  });
  client.getCurrencies(function(err, currencies) {
    console.log(' *************** Crypto Currencies *************** ');
    console.log(currencies);
    console.log(err);
  });
);

but unfortunately I'm getting this error:

Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1474:34)
    at TLSSocket.emit (events.js:310:20)
    at TLSSocket._finishInit (_tls_wrap.js:917:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:687:12) {
  code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}

already tried to run : npm config set strict-ssl false or npm config set registry http://registry.npmjs.org/ but it doesn't work. Could you help me? Many thanks.


Solution

  • Check that you have access to https://api.pro.coinbase.com and https://api-public.sandbox.pro.coinbase.com

    If not, your router/admin/provider may block this site in firewall and you don't have access to it. Related answer

    BTW. Package coinbase is deprecated, better use coinbase-pro-node