skip to Main Content

I have an existing Google Cloud Function that I am trying to call. I want to pass into it an Id and with that Id, the cloud function can run its operation in the background. I am new to cloud functions and would appreciate the help. When I call the function, I get the error "POST….500" and the error message says "INTERNAL". Here is the code I use to call the cloud function, I have declared a function that I call in an onClick event in a button:

import { httpsCallable } from "firebase/functions";

import { functions } from "../../../firebase/firebase";

/* Below is how I call the cloud function */

// handle payment confirmation
  const handlePayment = async () => {
    const confirmPayment = httpsCallable(
      functions,
      "loanV2Group-onManualRepay"
    );
    confirmPayment(loanId)
      .then((response) => {
        if (response.status === "success") {
          setIsConfirmed(true);
          setOpenSnackbar(true);
          handleClose();
        } else {
          setOpenSnackbar(true);
        }
      })
      .catch((error) => {
        console.log("Payment Confirmation Error: ", error);
      });
  };

Kindly help!! Thanks.

2

Answers


  1. It sounds like maybe the error is on the cloud side, not your calling code. Give that a look…

    Login or Signup to reply.
  2. As per documentations Cloud functions in app are called with arguments like as follows

    const confirmPayment = httpsCallable(
             functions, 
             "loanV2Group-onManualRepay"
          );
          confirmPayment({ variable: your_variable })
          .then((response) => {
                    if (response.status === "success") {
                        setIsConfirmed(true);
                        setOpenSnackbar(true);
                        handleClose();
                    } else {
                        setOpenSnackbar(true);
                    }
            })
            .catch((error) => {
                    console.log("Payment Confirmation Error: ", error);
            });
    
    

    According to the same documentation, it will work for cloud functions as well. The parameters for cloud functions are received in HTTP responses. You can use JSON-like syntax to send those arguments to the cloud function.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search