Is there a way to call the "Firebase" server function from a client application, say using Angular 2?

So, Firebase offers something called "functions", which is essentially a nodejs server that has preconfigured all the Firebase stuff and automatically handles all the scaling. I am wondering if there is a way to call a function inside the "functions" index.js file from an angular 2 application?

I need to use the npm firebase-admin module to check if a user’s email exists and then grab the uid for that user if this happens.

According to this link, I can customize the index.js file, for example:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// I'm actually not sure if this is how you do this part:
exports.getUserByEmail = (email) => {
  return admin.auth().getUserByEmail(email);
}

Is there a way I can call getUserByEmail()inside a component in my angular 2 application?

Thanks in advance!

+4
source share
2 answers

There are two main ways to call a cloud function directly from client code.

You can use a database trigger that responds when a location in your Firebase Realtime Database project changes.

You can also use an HTTP trigger that responds when accessing an HTTP endpoint. For a web application, you use any method that you want to invoke an XHR transaction.

, - . , .

SDK Firebase admin . .

+7

Firebase SDK 20 , HTTPS , - , , , , , uid, .. . : https://firebase.google.com/docs/functions/callable

0

Source: https://habr.com/ru/post/1674153/


All Articles