Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
How do I receive the context parameter in the a cloud function onCall?

I have a cloud function that is called by my front-side app in React Native. Here is my cloud function:

exports.listProducts = functions.https.onCall((temp, context) => {
  console.log("fired");
  return context;
});

And here is how I call the function:

    let temp = await functions().httpsCallable("listProducts")(
      null,
      firebase.auth().currentUser
    );

However, I can't acccess the context variable in my cloud function which according to docs should be the Firebase auth. And the console.log in that function does not give me a log.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Any parameters you pass to the callable function are available in the first parameter, which you call temp, but that the Firebase documentation refers to as data.

You don't need to pass the current user to the callable function yourself, as the Firebase SDK already handles that for you, and the server already decoded the current user into context.auth.

For more on both parameters and the auth context, have a look at the Firebase documentation on writing and deploying callable functions, which contains:

Use functions.https.onCall to create an HTTPS callable function. This method takes two parameters: data, and optional context:

// Saves a message to the Firebase Realtime Database but sanitizes the text by removing swearwords.
exports.addMessage = functions.https.onCall((data, context) => {
 // ...
});

For a callable function that saves a text message to the Realtime Database, for example, data could contain the message text, while context parameters represent user auth information:

// Message text passed from the client.
const text = data.text;
// Authentication / user information is automatically added to the request.
const uid = context.auth.uid;
const name = context.auth.token.name || null;
const picture = context.auth.token.picture || null;
const email = context.auth.token.email || null;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda