javascript - firebase 函数发布数据为空
问题描述
我正在尝试使用 firebase 功能发帖,我正在使用 Blaze 付款计划。无论如何,它无法将发布的数据获取到 TOP 级别的 send_email 函数。我什至还没有接到请求电话。req.body 返回 null,我不知道为什么。
exports.send_email = functions.https.onRequest((req, res) => {
console.debug(req.body); // THIS IS NULL
const url = 'https://www.google.com/recaptcha/api/siteverify?secret=<Omitted for security>&response=' + req.body.recaptchaReactive + '&remoteip=' + req.connection.remoteAddress;
request(url, (body) => {
//the body is the data that contains success message
body = JSON.parse(body); // We ALWAYS fail here.
console.log(body);
//check if the validation failed
if (!body) {
res.end({ success: false, 'message': "recaptcha failed" });
return console.log("failed")
}
if (body.success !== undefined && !data.success) {
res.end({ success: false, 'message': "recaptcha failed" });
return console.log("failed")
}
//if passed response success message to client
res.end({ "success": true, 'message': "recaptcha passed" });
});
});
我正在使用我的角度代码调用该函数,如下所示:
public formSubmit() {
if (this.contactForm.valid) {
console.log(this.contactForm.value);
this.httpClient.post<any>("/send_email", this.contactForm.value).subscribe(d => {
debugger;
console.log('sent...', d);
});
this.formSentSuccess = true;
} else {
}
}
该函数确实被调用,但似乎没有发送数据。我现在要做的就是取回recaptcha 数据。然后我会发送电子邮件
解决方案
推荐阅读
- python - 如何在使用 Azure 认知语音翻译 API 时使用 python sdk 识别说话者?
- python - 错误属性错误:“列表”对象没有属性“发送键”
- sql - Azure DB 上的简单 SQL 更新性能不佳
- arrays - `.=` 什么时候比 `=` 更有效?
- http - 使用 wrk 对 nginx 反向代理进行负载测试时如何找出大量非 2xx 或 3xx 响应背后的错误
- firebase - 是否有任何关于开发用户聊天消息屏幕的教程/链接,类似于 AirBnB 或 Instagram 等应用程序?
- python - 从 xml 到封面要求列表
- javascript - Node.js - Discord.js - 尝试在嵌套地图中导航。- UnhandledPromiseRejectionWarning
- product - 如何在产品编辑页面(管理员)Prestashop 中创建自定义字段
- java - 递归函数的 JUnit 测试(创建文件并比较大小)