Calling a firebase cloud function from nodejs

余生长醉 提交于 2021-02-05 11:44:26

问题


I want to call a cloud function from firebase from another nodejs server or just a nodejs script.

My firebase function is an onCall function.

I am using https://www.npmjs.com/package/firebase-admin for interacting with firebase but it doesn't seem to have a way of calling cloud functions...

Can I do it any other way? Like a http request?


回答1:


In short: You have to trigger http event.
Currently, firebase does support two invoke options.

If you read through documentation here and here, there is always has to be some trigger.
And firebase accept http request.
Even if you use mobile app from example one, under the hood, firebase SDK will make http request.

The other option is scheduled invocations, but as I get from comments, it's not what you're looking for.




回答2:


If you want to invoke a callable Function from server code, you will have to follow its protocol documentation in order to make sure the request is valid.

It's probably easier just to use a regular HTTP type function. It should be easy to share its logic with a callable function by sharing the common code in another normal JavaScript function.



来源:https://stackoverflow.com/questions/56344640/calling-a-firebase-cloud-function-from-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!