简体   繁体   English

参考错误! 未使用node.js / Runkit定义

[英]Reference error! Not defined using node.js / Runkit

I'm trying to use this https://npm.runkit.com/globalpayments-api script but I can't figure what I'm doing wrong. 我正在尝试使用此https://npm.runkit.com/globalpayments-api脚本,但我不知道自己在做什么错。

When I run the Runkit and add the first code to create a new Credit Card it throws error "ReferenceError: CreditCardData is not defined": 当我运行Runkit并添加第一个代码以创建新的信用卡时,它将引发错误“ ReferenceError:未定义CreditCardData”:

const card = new CreditCardData();
card.number = "4111111111111111";
card.expMonth = "12";
card.expYear = "2025";
card.cvn = "123";

How I can point CreditCardData to var globalpaymentsApi = require("globalpayments-api") which contains all this consts? 如何将CreditCardData指向包含所有这些const的var globalpaymentsApi = require(“ globalpayments-api”)?

Demo: https://runkit.com/embed/8hidbubpbk8n 演示: https : //runkit.com/embed/8hidbubpbk8n

What I'm doing wrong? 我做错了什么?

Most likely in your code, function CreditCardData() doesn't exist - this means you didn't import it. 在您的代码中,很可能函数CreditCardData()不存在-这意味着您没有导入它。 Try adding this at the beginning of your .js file: 尝试将其添加到.js文件的开头:

const { CreditCardData } = require('globalpayments-api');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM