简体   繁体   中英

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.

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. jumping to def doesn't seem to work either. I just want to see what my error is.

Here is link to docs:

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 .

If you have @types/stripe installed and import the Stripe API using import , TypeScript should be able to tell you this. In this case, you should use the special import-assignment syntax for modules with a CommonJS-style export assignment:

import stripeFactory = require("stripe");
var stripe = stripeFactory("sk_test_uTzXlltbjYmk6FISYoooBvFo");

If you have the esModuleInterop compiler option enabled, the following should also work:

import stripeFactory from "stripe";
var stripe = stripeFactory("sk_test_uTzXlltbjYmk6FISYoooBvFo");

Let me know if it doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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