0

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!

2 Answers 2

1

Change

return;

To

return null;

UPDATE

Or try this

db.runTransaction(transaction  => {
  return  transaction.getAll(...docRefCarsDetails); 
})
Sign up to request clarification or add additional context in comments.

2 Comments

Hi! Thank you for your reply. This suggestion did not work... Do you have any other idea?
Can you add the original java code for those two lines please?
0

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

 });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.