Android – use the firebase cloud function to read data from the cloud firewall?

I am an Android Developer. Recently, I began to study projects based on firebase cloud function and firestore database. I am writing an HTTP trigger function, which will obtain two parameters and compare the parameter value with the firestore data value. If the value matches, it will return true or other error responses

Repeat question:

Yes, some questions have been asked about me, but they are not similar:

Invalid Sign

Firebase documentation says:

I want to read the firestore value from the HTTP trigger

What I've tried:

exports.userData = functions.https.onRequest((req, res) => {

 const user = req.query.user;
 const pass = req.query.pass;
});

I almost insist on this part. Any help will be appreciated. Thank you

Attachment: my knowledge of JS / typescript / nodejs is very limited

resolvent:

It's a little late, but for anyone else who gets in the way

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


exports.someMethod = functions.https.onRequest((req, res) => {
    var stuff = [];
    var db = admin.firestore();
    db.collection("Users").doc("7vFjDJ63DmhcQiEHwl0M7hfL3Kt1").collection("blabla").get().then(snapshot => {

        snapshot.forEach(doc => {
            var newelement = {
                "id": doc.id,
                "xxxx": doc.data().xxx,
                "yyy": doc.data().yyy
            }
            stuff = stuff.concat(newelement);
        });
        res.send(stuff)
        return "";
    }).catch(reason => {
        res.send(reason)
    })
});

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>