【发布时间】:2017-12-24 16:49:28
【问题描述】:
我有一个具有主要功能的主要 Firebase 云功能。但我需要创建另一个更具体的使用主云功能的功能。我可以使用免费帐户从一个 firebase 云功能请求 http 发布或获取到另一个 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);
【问题讨论】:
-
你能分享你的代码吗?
-
编辑放代码
标签: javascript firebase google-cloud-functions