Joao Victor Cachola
Joao Victor Cachola

Reputation: 31

Firebase Functions with TypeScript - Expected at least 1 arguments, but got 0 or more

I was using Firebase Functions with javascript before and everything was working fine. Now i translated my code to typescript and when i try to update my functions, in one of them it complains about the following error:

Expected at least 1 arguments, but got 0 or more.

The block of code which causes the problem is this one:

  size  =  array.size;
  if (size  ===  0) {
  return;

 } else {
  array.forEach((doc  :  any) => {
  docRefCarsDetails.push(db.collection('cars').doc(doc.get('licensePlate')));
 })

  return  Promise.resolve(db.runTransaction(transaction  => {
    return  Promise.resolve(transaction.getAll(...docRefCarsDetails)); // <-- this is the problem
 }))

 }

And as you see i even tried to check the size to make sure that it will not happen.

Thanks for helping!

Upvotes: 0

Views: 756

Answers (2)

Andres Diaz Lopez
Andres Diaz Lopez

Reputation: 602

I found a comment that Help me. it is working well.

const corsHandler = cors({ origin: true }); // this is the solution

import cors from "cors";
const corsHandler = cors({ origin: true }); // this is the solution

// allow cors in http function
export const myFunction = functions.https.onRequest((req, res) => {
corsHandler(req, res, async () => {

// your method body

 });
});

Upvotes: 0

Mocas
Mocas

Reputation: 1660

Change

return;

To

return null;

UPDATE

Or try this

db.runTransaction(transaction  => {
  return  transaction.getAll(...docRefCarsDetails); 
})

Upvotes: 1

Related Questions