Kel*_*hao 5 httprequest express google-cloud-functions
我正在尝试使用以下代码触发对我的 firebase 云函数的 http 请求,
fetch( 'my-cloud-function-address', {
method: 'POST',
body: {
id: token.id,
email: token.email,
amount: 2100,
description: 'Full Deck'
}
})
.then( res => {
console.log( res )
})
Run Code Online (Sandbox Code Playgroud)
在我的云函数中,
const
functions = require( 'firebase-functions' ),
admin = require( 'firebase-admin' ),
cors = require( 'cors' )({ origin: true })
admin.initializeApp( functions.config().firebase )
exports.chargeCard = functions.https.onRequest( ( req, res ) => {
console.log( req, req.body )
cors( req, res, () => {
res.send( `Success!` )
} )
} )
Run Code Online (Sandbox Code Playgroud)
所以......一些问题......如果这是一个非常菜鸟的问题,请耐心等待,因为这是我第一次尝试http请求。
| 归档时间: |
|
| 查看次数: |
367 次 |
| 最近记录: |