Home » Javascript » Not able to call firebase https on call cloud functions

Not able to call firebase https on call cloud functions

Posted by: admin June 30, 2018 Leave a comment


I am trying to develop a friend request system for my website using cloud functions to send, receive, and accept the requests. Yet I am not able to call them. I scoured through all the docs and modified my code to meet the right protocol but still no cigar. Pretty lost at this point, any help would really be appreciated.

Heres my cloud function

exports.sendFriendRequest = functions.https.onCall((data, context) => {
    var jsonData = JSON.parse(data);
    var requestedUserProfileRef = firebase.database().ref("Users/" + jsonData["recievingUser"]);
    var pushKey = requestedUserProfileRef.key;

Heres how I am calling it, or trying to at least

function sendFriendRequest(userUid)
    //userUid is user that will recieve request
    var curUser = firebase.auth().currentUser;
    userUid = userUid.substring(1);
    var sendRequest = firebase.functions().httpsCallable('sendFriendRequest');
    sendRequest({"data": {"sendingUser": curUser.uid, "recievingUser": userUid}}).then(function(result) {});

Could it have something to do with not having a result returned?
Finally, here is the error that I am getting when I try and call the function

POST https://us-central1-accounts-cfe00.cloudfunctions.net/sendFriendRequest

Uncaught (in promise) Error: INTERNAL
at new t (firebase.js:1)
at _errorForResponse (firebase.js:1)
at e.<anonymous> (firebase.js:1)
at firebase.js:1
at Object.next (firebase.js:1)
at a (firebase.js:1)