Using TypeScript with Firebase Functions - Anticipated a minimum of one argument, yet received zero or more as input

Previously, I successfully used Firebase Functions with JavaScript. However, after translating my code to TypeScript, I encountered an issue while trying to update my functions. The error message I received is as follows:

Expected at least 1 argument, but received 0 or more.

The problematic block of code is shown below:

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)); 
  }))
}

I even attempted to check the size to prevent this error from occurring. Your assistance is greatly appreciated!

Answer №1

Modify

return;

Into

return null;

REVISION

Alternatively, attempt

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

Answer №2

This comment provided the exact solution I needed, and it's working perfectly.

const corsHandler = cors({ origin: true }); // the key to resolving the issue

import cors from "cors";
const corsHandler = cors({ origin: true }); // the essential fix

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

// your method implementation

 });
});

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

Create a new array in JavaScript by comparing and finding the differences between two existing arrays

I have two arrays - array1 and array2. I want to compare both arrays and create a new array (array3) with values that are unique to array1. For example, 'mob2', 'pin', 'address2', 'city' are present in array1 but no ...

Typescript - Iterating through CSV columns with precision

I am currently facing a challenge in TypeScript where I need to read a CSV file column by column. Here is an example of the CSV data: Prefix,Suffix Mr,Jr Mrs,Sr After researching on various Stack Overflow questions and reading through TypeScript document ...

Typescript is failing to compile classes in a reliable sequential order

In my MVC 5 project, I am using TypeScript and angular. There are three TS files: Controller1.ts, Controller2.ts, and app.ts. The issue arises when I compile the program for the first time - everything usually compiles correctly in the expected order. Howe ...

Dynamic addition of script to <head> element in Angular is a common task for many developers

I have explored some examples that illustrate how to dynamically add a script with a URL in Angular However, I am interested in adding this type of content to the <head> <script> !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(! ...

An issue has arisen with loading chunks in Ionic 5/Angular, possibly due to an un

I am currently working on enhancing the offline capabilities of my Ionic 5 app. To achieve this, I have implemented a strategy where data is stored in SQLite while the app is connected, and then retrieved from SQLite when offline instead of making HTTP req ...

Is it feasible to connect to an output component without using EventEmitter?

When it comes to creating components, I've found it quite easy to use property binding for inputs with multiple options available like input(). However, when dealing with component outputs, it can be a bit complicated as there's only one option u ...

Encountering an ERROR during the compilation of ./src/polyfills.ts while running ng test - Angular 6. The module build

I encountered a problem in an angular project I am working on where the karma.config was missing. To resolve this, I manually added it and attempted to run the test using the command ng test. However, during the execution, an error message appeared: [./src ...

The initial click may not gather all the information, but the subsequent click will capture all necessary data

Issue with button logging on second click instead of first, skipping object iteration function. I attempted using promises and async await on functions to solve this issue, but without success. // Button Code const btn = document.querySelector("button") ...

Is there a way to instruct Alexa/Jovo to incorporate just one render document in its response?

Within my project, there are multiple outputs, but I am specifically focused on an output that presents 2 directives: an APL and an APLA render document. My component is set up to handle this in the following way: @Handle({ global: true, prioritiz ...

Retrieving key values from an interface using Typescript

export interface Cookies { Token: string; SessionID: string; UserID: string; } type property = keyof Cookies // property is "Token" | "SessionID" | "UserID" export const COOKIE_PROPERTIES: Record<property, property& ...

Saving an array to a text file with a new line delimiter can easily be achieved using Types

I have an array of plain strings that I need to save to a text file. However, I'm encountering an issue where the strings are being saved as comma separated values instead of new lines. Here is the data I currently have: https://i.sstatic.net/r3XVr.j ...

Nuxt 3 is throwing a Vue warning regarding a hydration children mismatch in the <div> element. The server-rendered element has more child nodes than the client-side virtual DOM

Working with Nuxt 3 + Pinia + FirebaseStore in my project, I encountered an error "Hydration children mismatch" when wrapping my Firebase data loading functions within the AsyncData function. It has been challenging to find a solid solution or example of a ...

Why is NestJs having trouble resolving dependencies?

Recently delving into NestJs, I followed the configuration instructions outlined in https://docs.nestjs.com/techniques/database, but I am struggling to identify the issue within my code. Error: Nest cannot resolve dependencies of the AdminRepository ...

What methods can I use to eliminate redundant information from a dropdown selection?

<option *ngFor="let type of UserTypes; let i = index" [ngValue]="type.id"> <span>{{type.name}}</span> </option> I am looking for a solution to eliminate repeated data in the dropdown options. ...

transferring a LatLng variable from one function to initialize Google Maps

I have a database in firebase that stores latitude and longitude values which I retrieve as the variable coords. function getCoords() { var place_data= firebase.database().ref("/place/name"); place_data.once('value').then(function(snaps ...

Creating an interceptor to customize default repository methods in loopback4

Whenever I attempt to access the default repository code, I need to manipulate certain values before triggering the default crud function in the repository. How can I accomplish this? For example: ... @repository.getter('PersonRepository') priva ...

Encountering TS2304 error message while running TypeScript files indicates the inability to locate the name 'PropertyKey', in addition to another error - TS2339

I encountered an issue while attempting to execute a spec.ts file in the Jasmine Framework. After installing @types/core-js version 0.9.46 using the command npm i @types/core-js, I started receiving the following error messages: > ../../node_modules/ ...

The Typescript code manages to compile despite the potential issue with the type

In my coding example, I have created a Try type to represent results. The Failure type encompasses all possible failures, with 'Incorrect' not being one of them. Despite this, I have included Incorrect as a potential Failure. type Attempt<T, ...

Troubleshooting a NestJS application within an Nx workspace by configuring a VScode Launch setup

I am facing an issue in VSCode while trying to launch a NestJS application using Nx in debug mode. I have the VSCode nightly js debugger extension installed, but something seems to be going wrong. I attempted to add type "module" to the package.json file, ...

Record the variable as star symbols in the VSTS Extension

I am working on a VSTS extension using Typescript and utilizing the vsts-task-lib Currently, I am encountering an issue with the execSync function, which displays the command being executed. However, I need to hide a token obtained from a service by displ ...