我正在尝试将筹款整合到我的网站我使用快速js来运行它我已经通过了npm文档,但它似乎仍然不清楚,我尝试运行一些代码仍然没有显示。任何帮助都非常感谢。
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)
}
})
它在我的命令行中抛出错误
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
对此我不熟悉并不确定事情是如何运作的
问题在于此部分:
var client = new Coinpayments({
key: kfjdkjfkdfkf00d00, // <-- this line
secret: 009093403440349,
});
什么是kfjdkjfkdfkf00d00
?既不是aString
也不是Number
。这是一个未声明的变量。
因此,您将一个未声明的变量传递给Coinpayments
的构造函数,该构造函数从您提供的错误消息中获取undefined
的值。
所以你的实际构造函数看起来像:
var client = new Coinpayments({
key: undefined,
secret: 009093403440349,
});
换句话说,您需要定义key
值。