Parsing error: Unexpected token stripe? slint
Parsing error: Unexpected token stripe? slint
当我用 functions.https.onRequest((req, res) => {
替换 functions.auth.user().onCreate(async (user) => {
时,我最终收到以下错误:
Parsing error: Unexpected token stripeslint
我收到 strip.
的错误
const strip = require('stripe')('KeyString');
exports.createConnectAccount = functions.auth.user().onCreate(async (user) => {// functions.https.onRequest((req, res) => {
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/account/apikeys
const account = await strip.accounts.create({ //get error here: strip
type: 'express',
});
let refURL = account.refresh_url
let retURL = account.return_url
console.log("mi caca la caca 00>", account, retURL, refURL, account.uid, account.userId, account.userRef, account.user, account.id, account.ref, account.pushId, account.customer_id)
});
Packedge.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "index.js",
"dependencies": {
"@google-cloud/logging": "^9.1.0",
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0",
"stripe": "^8.56.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
您的代码中有两处需要调整:
- 声明 HTTPS 云函数时使用
async
关键字。 functions.https.onRequest(async (req, res) => {...}
.
- 使用
create()
方法的 promise 版本正确终止您的云函数。有关此关键方面的更多详细信息,请参阅 https://firebase.google.com/docs/functions/terminate-functions。
当我用 functions.https.onRequest((req, res) => {
替换 functions.auth.user().onCreate(async (user) => {
时,我最终收到以下错误:
Parsing error: Unexpected token stripeslint
我收到 strip.
const strip = require('stripe')('KeyString');
exports.createConnectAccount = functions.auth.user().onCreate(async (user) => {// functions.https.onRequest((req, res) => {
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/account/apikeys
const account = await strip.accounts.create({ //get error here: strip
type: 'express',
});
let refURL = account.refresh_url
let retURL = account.return_url
console.log("mi caca la caca 00>", account, retURL, refURL, account.uid, account.userId, account.userRef, account.user, account.id, account.ref, account.pushId, account.customer_id)
});
Packedge.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "index.js",
"dependencies": {
"@google-cloud/logging": "^9.1.0",
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0",
"stripe": "^8.56.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
您的代码中有两处需要调整:
- 声明 HTTPS 云函数时使用
async
关键字。functions.https.onRequest(async (req, res) => {...}
. - 使用
create()
方法的 promise 版本正确终止您的云函数。有关此关键方面的更多详细信息,请参阅 https://firebase.google.com/docs/functions/terminate-functions。