Rav*_*Rav 10 javascript node.js stripe-payments firebase google-cloud-functions
我正在使用 firebase 函数进行条带支付集成。此特定功能用于使用条带注册客户。
节点版本 10.15.3 ,
npm 版本 6.9.0 ,
"ecmaVersion": 6 in .eslintrc.json
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const stripe = require('stripe')(functions.config().stripe.testkey)
exports.createStripeCustomer = functions.auth.user()
.onCreate(async (user) => {
const customer = await
stripe.customers.create({email: user.email});
await admin.firestore()
.collection('stripe_customers')
.doc(user.uid)
.set({customer_id: customer.id});
});
Run Code Online (Sandbox Code Playgroud)
代码与 github 示例https://github.com/firebase/functions-samples/blob/master/stripe/functions/index.js上提供的 firebase 平台相同
解析错误:意外的令牌 =>
如果我将 .eslintrc.json 中的 "ecmaVersion": 6 更改为 "ecmaVersion": 8
then error is .onCreate(async (user) => {
^
SyntaxError: Unexpected token (
Run Code Online (Sandbox Code Playgroud)
我想正确部署功能,以便用户可以在 firebase 存储中的条带和日期存储上注册
确保您在本地机器节点上运行 >= 8。对于部署,您应该在 package.json 中有。
{
//...
"engines": {
"node": "8"
},
//...
}
Run Code Online (Sandbox Code Playgroud)
对于 eslint,要启用异步函数解析,您应该在配置中包含以下内容:
{
"parserOptions": {
"ecmaVersion": 2017
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7626 次 |
| 最近记录: |