express - 在 Firebase 云函数中表达响应 XML RSS 提要
问题描述
我正在尝试在 /feeds 根目录下向我的访问者提供 RSS 源
我正在使用react-redux-firebase
Net Ninja 的模板
现在我在我的云函数文件中导入节点 Express,如下所示:
const functions = require('firebase-functions');
const admin = require('firebase-admin'); //init admin SDK to use auth, firestore ...
const express = require('express');
const firebaseApp = admin.initializeApp(functions.config().firebase);
const app = express();
getFeeds = () => {
const ref = firebaseApp.database().ref('projects');
return ref.once('value').then(snap => snap.val());
};
app.get('/feeds', (request, response) => {
response.set('Cashe-Control', 'public, max-age=300, s-maxage=600')
getFeeds().then(feeds => {
// response.send(feeds);
response.send(`${Date.now()}, this is feeds: ${feeds}`);
});
});
exports.app = functions.https.onRequest(app);
但只有当我使用( firebase serve --only functions, hosting)
然后当我去http://localhost:5000/feeds时:我明白了
1552472467200, this is the feeds: null
这正在打印到我的控制台:
[hosting] Rewriting /feeds to local function app
info: User function triggered, starting execution
info: Execution took 126 ms, user function completed successfully
127.0.0.1 - - [13/Mar/2019:10:21:07 +0000] "GET /feeds HTTP/1.1" 200 34 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
这是为什么?
解决方案
推荐阅读
- r - 大样本量(180 万观察)的逻辑回归预测器仅预测 0
- linux - 在linux中使用长度重定向文件
- amazon-web-services - AWS IAM 策略模拟器:如果至少有一个区域允许操作,如何返回 true
- javascript - 用Java Script检查圆的位置
- angular - 如何在测试期间获取动态角度分量的实例?
- postgresql - 随机双精度
- javascript - 如何制作禁用的“Apple登录按钮”?
- c# - 如何从 Xamarin Forms 中的自定义 ViewCell 获取 ListView 项目索引?
- python - 熊猫在时间序列中每 30 分钟填充一次缺失的日期
- angular - 从 Angular 7 升级后,I18n 本地化/合并在 Angular 10 中不起作用