0

am trying to integrate coinpayments into my site am using express js to run it i have gone through the npm docs but it still seems unclear to me and i have tried running some code and still nothing shows up. Any help is highly appreciated.

var express           = require("express"),
      app                 = express(),
      coinpayments = require("coinpayments"),
      bodyparser      = require("body-parser")

      app.use(bodyParser.urlencoded({extended: true}));
var Coinpayments = require('coinpayments');
var client = new Coinpayments({
      key: kfjdkjfkdfkf00d00,
      secret: 009093403440349,
});

client.getBasicInfo(function(error,result){
    if(error){
        console.log(error)
    } else{
        console.log(result)
    }
})

it throws up error in my command line

sniperfillipo:~/workspace/bitcointest/main $ node crypto.js 
/home/ubuntu/workspace/bitcointest/main/node_modules/coinpayments/lib/index.js:28
            throw new Error('Missing public key and/or secret');
            ^

Error: Missing public key and/or secret
    at new CoinPayments (/home/ubuntu/workspace/bitcointest/main/node_modules/coinpayments/lib/index.js:28:19)
    at Object.<anonymous> (/home/ubuntu/workspace/bitcointest/main/crypto.js:235:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

Am new to this don't really know for sure how things work

wowkin2
  • 5,895
  • 5
  • 23
  • 66
Fillipo Sniper
  • 419
  • 2
  • 11
  • 28
  • You're trying to use variables that don't even exist. It would be helpful if you post the exact error you are getting. – Cisco Feb 10 '18 at 01:14
  • @FranciscoMateo I already updated my question. It throws up an error in my command line missing public key or secret. :) for replying – Fillipo Sniper Feb 12 '18 at 15:00

1 Answers1

1

The issue is this section here:

var client = new Coinpayments({
      key: kfjdkjfkdfkf00d00,   // <-- this line
      secret: 009093403440349,
});

What is kfjdkjfkdfkf00d00? It is neither aString nor a Number. It is an undeclared variable.

So you are passing an undeclared variable into the constructor of Coinpayments which takes on the value of undefined judging from the error message you provided.

So your actual constructor looks like:

var client = new Coinpayments({
      key: undefined,
      secret: 009093403440349,
});

In other words, you need to define your key value.

Cisco
  • 20,972
  • 5
  • 38
  • 60
  • yeah your answer was useful but the api key that they give is a combination of both number and letters maybe you should have a look at their docs (https://www.npmjs.com/package/coinpayments). i cant show my keys here maybe you can send me your email to chat you up, help keeping here dry :) for replying @FranciscoMateo – Fillipo Sniper Feb 12 '18 at 19:35
  • Then it's a string value and so should be `"kfjdkjfkdfkf00d00"` not `kfjdkjfkdfkf00d00` – Cisco Feb 12 '18 at 19:55