[英]How to find out what types are returned in promises Java script
I am trying to use stripe for the payment solution for my client. 我正在尝试将Stripe用于我的客户的付款解决方案。
here is the example code strait from documentation im trying to use: 这是试图使用的文档中的示例代码海峡:
var stripe = require("stripe")("sk_test_uTzXlltbjYmk6FISYoooBvFo");
stripe.accounts.retrieve(
"acct_1DEnU3AqtajnnBvl",
function(err, account) {
// asynchronously called
}
);
when I try to do error handling the err param is of type any, and I cant find out how to log what error is actually occurring. 当我尝试执行错误处理时,err参数的类型为any,并且我无法找到如何记录实际发生的错误的信息。 jumping to def doesn't seem to work either.
跳到def似乎也不起作用。 I just want to see what my error is.
我只想看看我的错误是什么。
Here is link to docs: 这里是文档链接:
https://stripe.com/docs/api?lang=node#create_account https://stripe.com/docs/api?lang=node#create_account
According to the typings, the callbacks are of type IResponseFn<R>
, which takes an error parameter of type IStripeError
. 根据类型,回调的类型为
IResponseFn<R>
,该类型的错误参数为IStripeError
类型。
If you have @types/stripe
installed and import the Stripe API using import
, TypeScript should be able to tell you this. 如果您已安装
@types/stripe
并使用import
导入Stripe API,TypeScript应该可以告诉您这一点。 In this case, you should use the special import-assignment syntax for modules with a CommonJS-style export assignment: 在这种情况下,对于具有CommonJS样式的导出分配的模块,应使用特殊的import-assignment语法:
import stripeFactory = require("stripe");
var stripe = stripeFactory("sk_test_uTzXlltbjYmk6FISYoooBvFo");
If you have the esModuleInterop
compiler option enabled, the following should also work: 如果启用了
esModuleInterop
编译器选项,则以下内容也应起作用:
import stripeFactory from "stripe";
var stripe = stripeFactory("sk_test_uTzXlltbjYmk6FISYoooBvFo");
Let me know if it doesn't work. 让我知道它是否无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.