Problem encountered while saving data to firestore

Encountering difficulties when attempting to save and retrieve data from firestore. The code snippet provided below is failing, despite its simplicity and my stable internet connection. Even upgrading to websdk 5.0.4 has not fixed the issue.

save = async (data: any) => {
    try {
      const { id, ...rest } = data;
      await db
        .collection('/customers')
        .doc(id)
        .set({ ...rest });

      const saved = await db
        .collection('/customers')
        .doc(data.id)
        .get();
      console.log(saved.data());
    } catch (error) {
      console.log(error);
    }
  };

Upon debugging, I noticed the following:

[2018-05-28T13:09:19.910Z] @firebase/firestore: Firestore (5.0.3) [PersistentStream]: close with error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: _lat index.esm.js:65 [2018-05-28T13:09:19.915Z] @firebase/firestore: Firestore (5.0.3) [ExponentialBackoff]: Backing off for 46014.29558926278 ms (base delay: 60000 ms) index.esm.js:65 [2018-05-28T13:10:06.122Z] @firebase/firestore: Firestore (5.0.3) [PersistentStream]: close with error: FirebaseError: [code=unknown]: Fetching auth token failed: Cannot redefine property: _lat

Answer №1

An easy way to add data into a firestore database and verify responses:

//---creating reference---
  const dataRef = this.db.collection('data');

  //---inserting into the database---
  dataRef.set({
    title: 'exampleTitle',
    content: 'exampleContent',
  }).then(response => {
    console.log('response: ', response);
  })
    .catch(function (error) {
      console.log('Error: ', error);
    });

Also, ensure that RULES in the firebase database console are properly set up for testing purposes:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

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

I am looking for a guideline that permits me to restrict the use of a form validation tool

We have developed our own version of the Validators.required form-validator that comes with Angular 7, but now we need to switch to using CustomValidators.required. To enforce this change, we are considering banning the use of the old Validators.required b ...

What is the process for creating a personalized tag?

Having created a component similar to the one below. In MyButton.tsx import React from 'react'; import { Button } from '@material-ui/core'; import { Theme, makeStyles, createStyles } from "@material-ui/core/styles"; interface IMyButt ...

Guide on incorporating text input areas into specific positions within a string

Looking for a way to replace specific words in a string with input fields to enter actual values? For example... Dear Mr. [Father_name], your son/daughter [name] did not attend class today. This is what I want it to look like... Dear Mr. Shankar, your ...

Automatically expanding PrimeNG Turbotable rows

I am using a PrimeNg turbotable that has a row expansion feature enabled. I am looking for a way to automatically expand the rows by default when the table loads. Shown below is my code: HTML <p-table [columns]="cols" [value]="cars" dataKey="vin"> ...

Creating a digital collection using Vue, Typescript, and Webpack

A short while back, I made the decision to transform my Vue project into a library in order to make it easier to reuse the components across different projects. Following some guidelines, I successfully converted the project into a library. However, when ...

Exploring Typescript: A Guide to Conditional Branching Based on Type

I encountered the following scenario: interface C { c1: string; c2: number; c3: boolean; } interface D { d1: number; d2: boolean; d3: string; } function bar<K1 extends keyof C, K2 extends keyof D>(entry: K1 | K2) { if (entry includes ...

Visual Studio Code is unable to identify the TypeScript module located within the `node_modules` directory

After cloning the tslint repository, running npm install and grunt as instructed in the README, I opened the folder in Visual Studio Code (0.9.1). Upon inspecting a .ts file such as src/rules/typedefRule.ts, TypeScript errors appeared regarding the require ...

Verify the attribute of the child element

In my child component, I have a property named files, which is an input type=file. This property allows me to determine if the user has selected a file for upload so that I can disable the submit button if no files are present in the input field. The issue ...

How can I dispatch multiple actions simultaneously within a single epic using redux-observable?

I am a newcomer to rxjs/redux observable and have two goals in mind: 1) enhance this epic to follow best practices 2) dispatch two actions from a single epic Many of the examples I've come across assume that the API library will throw an exception ...

Establishing a secure Firebase connection with several Node.js instances via an AWS/ALB load balancer and Nginx

Looking to establish a connection between Firebase and a Node setup deployed on AWS/Elastic Beanstalk. The architecture includes 1-4 Node servers operating behind an ALB load balancer and Nginx proxy. Because Firebase requires WSS protocol, the ALB is nece ...

What are the steps to incorporating a personalized component into an extension?

I am working on a TypeScript file that includes a class inheriting cc.Component. My goal is to package this file as an extension and make it easily accessible within the editor, allowing users to add it to a node with ease. What steps should I take to ac ...

Retrieving an Observable within an Observable is a feature found in Angular 9

Seeking a solution to return an Observable nested within another Observable. Although I've tried using the pipe and map operators, it doesn't appear to be functioning correctly for me. What could be causing the issue? My development environment ...

Is there a way to customize the language used for the months and days on the DatePicker

Is there a way to change the language of the DatePicker (months and days) in Material UI? I have attempted to implement localization through both the theme and LocalizationProvider, but neither method seems to work. Here are some resources I have looked a ...

Return true for cucumber datatable in typescript without fail

I am facing an issue where the following step definition always returns true even for incorrect data from the dataTable. Can someone assist me in correcting the syntax in TypeScript with Chai assertions? Then(/^Verify the following details in report$/, a ...

Unusual actions observed in Ionic 3 app using webview 3 plugin

I am currently facing a significant problem with Webview 3. One of our developers upgraded it to webview 3 without utilizing the Ionic native webview plugin, and surprisingly, it is functioning well on our Ionic 3 application. As per the documentation avai ...

Using Typescript: A guide on including imported images in the output directory

typings/index.d.ts declare module "*.svg"; declare module "*.png"; declare module "*.jpg"; tsconfig.json { "compilerOptions": { "module": "commonjs", "target": "es5", "declaration": true, "outDir": "./dist" }, ...

Expanding external type declarations within Typescript

I am currently working with Typescript and the ant design library. My goal is to extend an existing interface by adding a single property. To start, I imported the original interface so you can see the folder structure: import { CollapseProps } from &apo ...

Display a customized modal showcasing the data of a particular user

Seeking advice on how to pass data to a modal based on a specific user. I have an array with user information and would like to display their name and email in a modal when the user is clicked on. Any suggestions on how to accomplish this? ...

Javascript operations for duplicating and altering arrays

In my Angular application, I am working with an array called subAgencies that is connected to a datasource. I need to implement 2-way binding on this array. Currently, I have a method in place where I copy the contents of the original array to a new one, ...

Synchronization Discrepancy in Swift and Firebase following isPersistenceEnabled setting

I am experiencing an issue with the connection between my app and Firebase database. After adding the following code to my AppDelegate: Database.database().isPersistenceEnabled = true Some of the data is not syncing properly. When fetching the data, I us ...