我正在使用Braintree nodejs Sdk作为我的一个项目,
我有问题使用customer.find()函数.
origina link is here
我有问题使用customer.find()函数.
origina link is here
当我以这种方式直接传递像’207’的用户ID时,它正在工作.
var braintree = require("braintree"); var gateway = require("./bt"); gateway.customer.find('207',function(err,customer) { console.log("customer:",customer); });
但是当我试图传递动态id时,它不起作用;
btuserID = data.userId; gateway.customer.find(btuserID,customer); });
我认为它的参数类型是字符串,所以如何在没有双引号的情况下传递参数?
完成错误:
/home/api/node_modules/loopback-connector-MysqL/node_modules/MysqL/lib/protocol/Parser.js:82 throw err; ^ TypeError: undefined is not a function at CustomerGateway.find (/home/api/node_modules/braintree/lib/braintree/customer_gateway.js:37:20)
解决方法
如果你试试
console.log(typeof(btuserID));
我怀疑你会看到类型是一个数字,如果是这样,那么尝试下面的建议.
将您的分配更改为此以将数字转换为字符串.
btuserID = data.userId.toString();
如果您查看braintree Node.js库的源代码,您将看到它首先尝试修剪字符串.如果你对一个数字执行此操作,您可能会失败.
https://github.com/braintree/braintree_node/blob/master/src/braintree/customer_gateway.coffee
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。