0

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.

Vinni
  • 191
  • 2
  • 2
  • 11
  • Does this answer your question? [Nodejs https request UNABLE\_TO\_GET\_ISSUER\_CERT\_LOCALLY](https://stackoverflow.com/questions/30651407/nodejs-https-request-unable-to-get-issuer-cert-locally) – NiRUS May 04 '20 at 19:04
  • and also try this solution - https://stackoverflow.com/a/52007971/1848109 – NiRUS May 04 '20 at 19:06
  • I am having the same problem. Did you solve it? – pinturic Apr 01 '21 at 22:05

1 Answers1

1

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

Damian Plewa
  • 1,123
  • 7
  • 13
  • I have access to the site to which the library is connecting (which is api.coinbase.com) and the coinbase-pro-node is not a superset of the other library; it is simply a new library that you can use only if you have a coinbase pro account – pinturic Apr 01 '21 at 22:06