Stripe payments 使用stripe Node.js库访问stripe API
我正在尝试从本地主机调用stripe API stripe.subscriptions.retrieve,没有响应,没有错误 我试过以下方法:Stripe payments 使用stripe Node.js库访问stripe API,stripe-payments,stripe-api,Stripe Payments,Stripe Api,我正在尝试从本地主机调用stripe API stripe.subscriptions.retrieve,没有响应,没有错误 我试过以下方法: const stripe = new Stripe('sk_testkey'); stripe.subscriptions.retrieve('subscriptionid') .then(subscription=> { console.log("complete")
const stripe = new Stripe('sk_testkey');
stripe.subscriptions.retrieve('subscriptionid')
.then(subscription=> {
console.log("complete")
console.log(subscription.data())
})
.catch(error => {
console.log("error")
console.error(error)}
);
及
适用于以下Axios:
var token = "sk_testkey"
const config = {
headers: { Authorization: `Bearer ${token}` }
};
// Make a request for a user with a given ID
axios.get('https://api.stripe.com/v1/subscriptions/subscriptionid',config).then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
有什么想法吗?运行该代码时,控制台的实际输出是什么?看起来您应该在控制台输出中看到一些东西。
var token = "sk_testkey"
const config = {
headers: { Authorization: `Bearer ${token}` }
};
// Make a request for a user with a given ID
axios.get('https://api.stripe.com/v1/subscriptions/subscriptionid',config).then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});