Luc*_*ara 5 javascript firebase google-cloud-functions
我有一个主要的firebase云功能,主要功能.但我需要创建另一个更具体的,使用主云功能的功能.我是否可以通过免费帐户请求http Post或从一个firebase云功能获取到另一个firebase云功能?
我试图制作它,但我得到了'ENOTFOUND'消息,我想知道我的代码是否有问题,或者它只是免费帐户的限制.
index.js'use strict';
const functions = require('firebase-functions');
const express = require('express');
const app = express();
app.post('/test', function(req, res) {
var request = require('request')
var options = {
method: 'post',
body: req.body, // re-send the incoming body to the main cloud function
json: true,
url: '<main cloud url>',
headers: req.headers // re-send the incoming headers the main cloud function
}
request(options, function (err, response, body) {
if (err || response.statusCode != 200) {
res.status(400).send(err); //re-send the received error to the client
return
}
res.send(body); //re-send the received response to the client
});
});
exports.checkAtivation = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)
目前,Spark计划无法从另一个HTTP云功能调用HTTP云功能.您必须升级到Blaze计划.
对于一个项目的函数来说,通过HTTP调用其他函数大多没有意义.如果您只是将逻辑抽象为所有端点可以共享的单个函数或模块,则可以在所有函数之间共享项目中的所有代码.
归档时间: |
|
查看次数: |
1062 次 |
最近记录: |