gpt4 book ai didi

node.js - Promisify Node 模块上的所有子方法

转载 作者:太空宇宙 更新时间:2023-11-04 02:11:51 25 4
gpt4 key购买 nike

我正在尝试 Promisify stripe 模块,但遇到了问题。

如果我运行:

const stripe = Promise.promisifyAll(require('stripe')(secretKey));
const response = await stripe.accounts.retrieveAsync();

retrieveAsync 不是函数。我必须做这样的事情:

const accounts = Promise.promisifyAll(stripe.accounts);
const response = await accounts.retrieveAsync();

但显然这不能很好地扩展。我怎样才能 promise 这个模块的所有子方法?谢谢

最佳答案

这似乎有效:

let stripe = require('stripe')(secretKey);
Promise.promisifyAll(Object.getPrototypeOf(stripe));

关于node.js - Promisify Node 模块上的所有子方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41734436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com