问题
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