Friday, 28 April 2017

Firebase HTTP cloud function .send() what does it return?

I'm trying get a value from a firebase cloud function with my Android App.

The cloud function is the following:

 exports.checkIfNumberExists = functions.https.onRequest((request, response) => {
    var db = admin.database();
    var ref = db.ref("numbers");
    var query = ref.orderByKey();
    var exists = "false";
    query.once("value" ,function(snapshot){
            snapshot.forEach(function(childSnapshot){
                if(childSnapshot.key === request.query.number){
                    exists = "true";
                }
            });
            response.send(exists);
        });
 });

I don't understand what type of data does that .send() function return, I asume it is plain text, but yesterday firefox got it as json when the exist value was boolean and not string.

Opening the url with firefox returns true or false, but when I try to make an http get request from Android or Javascript it denies access to it.

What is the return type of .send() function?



via Patxiku

No comments:

Post a Comment