bennycode/coinbase-pro-node

API not being called within express router

ryanbrwr opened this issue · 5 comments

Not sure if this is the right place to get help with this, but figured I'd give it a shot. Trying to make a call to this library on an api request from express, but the client never seems to actually do the request, just kinda hangs.

var express = require("express");
var router = express.Router();
var { CoinbasePro } = require('coinbase-pro-node');

router.get("/", function (req, res, next) {
    let query = req.query

    var auth = {
        apiKey: query.api_key,
        apiSecret: query.secret_key,
        passphrase: query.passphrase,
    };
    
    var client = new CoinbasePro(auth);

    client.rest.account.listAccounts().then(accounts => {
        const message = `You can trade "${accounts.length}" different pairs.`;
        res.send(message)

    }).catch((error) => {
        res.send(error)
    })
});

module.exports = router;

any explanation why anything else works in this route except this library would be appreciated

I see the section about setting up a proxy, but I want to do all of the functions with Coinbase inside of the backend, how can I get this to work?

Hi @ryanbrwr, you need to set a useSandbox property to auth. Set it to false, if you want to use the Coinbase Pro production environment.

Great I'll try this out! Appreciate the help with this simple question lol

@ryanbrwr, have you been successful with it?

yes I was successful, thank you!