Encountering an error with the Firebase cloud functions SDK when making a

I have a Python-based Firebase cloud function named hello_world_fn:

from firebase_functions import https_fn
from firebase_admin import firestore
import google.cloud.firestore

@https_fn.on_request()
def hello_world_fn(req: https_fn.Request) -> https_fn.Response:
    return "hello world"

In my Next JS project, I utilize this React code to execute the function:

const functions = getFunctions()
const helloWorld = httpsCallable(functions, "hello_world_fn")
const result = await helloWorld({})
console.log(result)

I am able to successfully run the cloud function via Postman, and the permission is configured for allUsers on Google Cloud Console for testing purposes.

Is there something incorrect in my setup?

Answer №1

You seem to be confusing HTTP events with callable functions. These two function types have distinct behavior, so I suggest reviewing the documentation to fully grasp the distinction. In Python, callable functions are marked with @https_fn.on_call(), not the current @https_fn.on_request().

Your application's client is attempting to call a callable function, but your server-side code defines an HTTP function instead. To resolve this issue, you'll need to align either the client or the backend to use the same function type. If you wish to continue using a callable function for the client, you'll need to implement a matching callable function on the server.

For more insights, check out:

  • Are Callable Cloud Functions better than HTTP functions?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Iterate through an array of objects and add them to a fresh array

I am encountering an issue where I would like to generate a fresh array of objects in order to avoid utilizing a nested array map. However, the error message below is being displayed: TypeError: Cannot read property 'subscriber_data' of undefine ...

Placing an interactive overlay on top of a button component within Material UI

Currently, I am attempting to place a button on top of another button in Material UI: Click here for the demo I want to ensure that clicking the X button only prints B, instead of both A and B. Although I am aware that nesting buttons is not the proper w ...

What is the best way to position my two icons next to each other in the footer of my React application?

I'm struggling with styling the footer of my react portfolio project. I specifically want to include Github and LinkedIn icons side-by-side at the bottom of the screen, but currently, they are stacked vertically in the middle of the page with too much ...

Alter the content of Material-UI ListItem when in hover or active state

Imagine a scenario where you have a side-bar navigation with the following component structure: <ListItem button dense component={CustomNavLink} to="/dashboard"> <ListItemIcon> <DashboardIcon /> </ListItemIcon ...

Having difficulties in Vue while attempting to access a particular row

I encountered an error message stating Uncaught TypeError: snapShotChnaged.forEach is not a function. My goal is to retrieve specific row data, which is why I am utilizing the doc method. retrieveSpecificDonation() { firestore .collection('d ...

Mastering the utilization of API routes within the Next JS 13 App Router framework

As a newcomer to React JS and Next.js, I recently made the switch from using the Page Router API in Next.js to utilizing the new App Router introduced in Next.js 13. Previously, with the Page Router, creating a single GET request involved nesting your "JS ...

Jest in combination with Next/Dynamic is causing an error that is not supported

While working on testing for my component, I encountered an error involving the use of: ... const Rating = dynamic(import('components/Rating')); ... In addition, I am utilizing jest-next-dynamic: beforeAll(async () => { await preloadAll() ...

Encountering difficulty in identifying the error during data fetching on the server side of a Next.js application

I am attempting to troubleshoot an error with my Next.js server-side data fetching, but I am encountering two problems. export async function getStaticProps() { try { const fetchUrl = "some api url"; const resp = await axios.get(fetchUrl); ...

What is the process for downloading a package from unpkg or adding an unpkg package to dependencies?

Challenge I attempted to install IPFS from the unpkg website. https://www.unpkg.com/browse/[email protected] / My Project This is a project built with React. Unfortunately, I am having trouble downloading this package or installing it in my packa ...

The chart refreshes whenever there is a change in the component's state

Whenever I click the button to use the changeState method, the state changes and the MoreInfo component appears. However, the chart is being drawn again as shown in this GIF: Below is the code snippet: import React from 'react' import './Ho ...

Python - Optimize code by eliminating the use of list in a global variable

As I dive into developing a ledger implementation, I find myself opening multiple transaction files from an index file. These transactions follow a specific format, which I parse and store in objects named 'transaction'. All these objects are the ...

Obtaining pairs within a Python list: one element and the remaining items

I am interested in this task: from some_cool_library import fancy_calculation arr = [1,2,3,4,5] for i, item in enumerate(arr): the_rest = arr[:i] + arr[i+1:] print(item, fancy_calculation(the_rest)) [Expected output:] # The fancy results from t ...

What steps can I take to make sure that a sub component's props are refreshed properly?

I'm encountering an issue with RTK queries in my project. I have a parent component that contains a table component. When a refresh event occurs, such as deleting data, the parent component receives updated data and passes it down to the child compone ...

How do I include an icon on the far left of my NavBar menu? I'm having trouble figuring out how to add an icon to the header NavBar

How can I add an icon to the left of my NavBar header? I am struggling with adding an icon on the far left side of my NavBar. The NavBar is a custom class from NavBar.js. I want to include an icon in this bar on the leftmost side. I have already added b ...

Error: Unable to retrieve current location using 'Geolocation' in React

import "./App.css"; import { useState, useEffect } from "react"; function App() { const [lat, setLat] = useState(null); const [long, setLong] = useState(null); const [data, setData] = useState(null); const [error, setError] = u ...

What is the best way to combine neighboring NumPy rows with matching values in the final column to create a consolidated row?

How can we solve this particular issue? I have an array with 30 rows containing columns (seq, high, low, status). The objective is to merge similar rows only when they are adjacent to each other in the sequence. The resulting row will have the maximum high ...

Next.js - NextAuth consistently delivers a successful status code every time

In my Next.js project, I am utilizing NextAuth. The issue I'm encountering is that NextAuth consistently returns a 200 status code and updates the session to authenticated, even when the username or password doesn't match. I've attempted thr ...

Explain the concept of a keyword argument in Python

As a newcomer to django, I am navigating my way through Class Based Views. However, I seem to be encountering the following error frequently: Reverse for 'products.views.'filter_by_led' with arguments '()' and keyword arguments ...

Error: The window object is not found in this context when initializing the Commerce module from the commerce.export.js file located in the node_modules folder within the @chec

I have been working with the pages router and custom app file (_app.js) https://nextjs.org/docs/pages/building-your-application/routing/custom-app It seems that the issue may be within my _app.js file, where I have the following code: import '../glo ...

Using Sqlalchemy to apply a filter on an object

I am currently working on a script that will test various conditions of objects within a SQLAlachemy ORM driven database. The dynamic nature of this process has presented some challenges for me. My goal is to query the minimum number of objects for all te ...