使用firebase云端功能将POST请求发送到非谷歌服务器 [英] Use firebase cloud function to send POST request to non-google server

查看:125
本文介绍了使用firebase云端功能将POST请求发送到非谷歌服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能使用Firebase云端功能向非Google服务器发送发布请求(从我所能找到的我需要在大火计划中才能与非Google服务器进行交互)

/ p>

基本上,我想要在运行在arduino上的外部服务器POST时,只要将值添加到我的数据库中。 >我浏览了文档,发现有一个云功能响应HTTP请求(HTTP云功能)的例子,但似乎无法找到任何发布到外部服务器的例子。这可能吗?

解决方案

是的,您可以。您只需要使用'request'模块,
您的代码如下所示:

模块调用:

var request = require('request');



/ p>

 请求('把你的外部URL放在这里',函数(error,response,body){
if(!error && amp;& response.statusCode == 200){
//这里把你想要做的要求
}
})



编辑:只能在付费计划中使用,不可以使用免费计划。


I was wondering if its possible to use a firebase cloud function to send a post request to a non-google server (from what I can find I need to be on the blaze plan in order to interact with non google servers)

Basically I want to POST to an external server running on an arduino whenever a value is added to my database.

I have looked through the docs and found examples of having a cloud function respond to an HTTP post request (HTTP cloud functions) but can't seem to find any examples of posting to an external server. Is this possible?

解决方案

Yes, you can. You just need to use 'request' module, Your code will look like this:

module call:

var request = require('request');

and the code for the request:

request('put your external url here', function (error, response, body) {
    if (!error && response.statusCode == 200) {
        //here put what you want to do with the request
    }
})

Edit: Work only on paid plans, it's not possible to do that with free plans.

这篇关于使用firebase云端功能将POST请求发送到非谷歌服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆