Fetching a firestore document from node.js errors

obnoxiousnerd

The code:

(global as any).XMLHttpRequest = require("xhr2");

import firebase from "firebase/app";
import "firebase/firestore";

// All are fake values
const firebaseConfig = {
  apiKey: "dsfds",
  authDomain: "sdf.firebaseapp.com",
  databaseURL: "https://sdfs.firebaseio.com",
  projectId: "dssdf",
  storageBucket: "sdsdfsdf.appspot.com",
  messagingSenderId: "wearwefas",
  appId: "asdfgerhdfgdettgerg",
  measurementId: "sdfgsregserg",
};

const app = firebase.initializeApp(firebaseConfig);
app
  .firestore()
  .doc("foo/bar")
  .get()
  .then((doc) => {
    console.log(doc.data());
  })
  .catch((e) => {
    throw e;
  });

Firebase SDK version: 7.19.1

The code is bundled with esbuild, which produces the same bundle as of rollup.

When ran in the terminal, it outputs :

[2020-09-10T13:35:55.539Z]  @firebase/app:
      Warning: This is a browser-targeted Firebase bundle but it appears it is being
      run in a Node environment.  If running in a Node environment, make sure you
      are using the bundle specified by the "main" field in package.json.

      If you are using Webpack, you can specify "main" as the first item in
      "resolve.mainFields":
      https://webpack.js.org/configuration/resolve/#resolvemainfields

      If using Rollup, use the rollup-plugin-node-resolve plugin and specify "main"
      as the first item in "mainFields", e.g. ['main', 'module'].
      https://github.com/rollup/rollup-plugin-node-resolve

Discarding entity body for GET requests
[2020-09-10T13:36:05.559Z]  @firebase/firestore: Firestore (7.19.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
(node:4104) UnhandledPromiseRejectionWarning: FirebaseError: Failed to get document because the client is offline.
    at new n2 (F:\Workspaces\Git Repos\lookahead\packages\cli\lib\index.js:5357:20)
    at next (F:\Workspaces\Git Repos\lookahead\packages\cli\lib\index.js:14649:50)
    at Timeout._onTimeout (F:\Workspaces\Git Repos\lookahead\packages\cli\lib\index.js:13615:19)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
(node:4104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Discarding entity body for GET requests
Discarding entity body for GET requests
Discarding entity body for GET requests

I am connected to the internet but it shows that I am offline. How do I fix this??

constexpr

This should work in esbuild version 0.7.0 (just released) as long as you use --platform=node.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Kotlin Firestore - Fetching Fields from Specific Document

Get document id from Firestore after fetching document

Get first Firestore document from an order of documents (Node.js)

Unable to load 'protobuf.js' when fetching Firestore document

How to show Circular progress indicator while fetching document from Firestore

Fetching an image from a website with Node.js

Multiple document reads in node js Firestore transaction

Fetching data from Firestore

Obtaining DocumentReference of Firestore document without fetching document

Fetching json from node.js in angular.js 1

Firestore recycler adapter not fetching document names

Fetching node from xml

Node.js puppeteer - Fetching content from a complex txt file

fetching POST data from API (node js, react)

Node JS Fetching JSON from url is executing AFTER the rest of the code

Fetching last record from mongodb using node.js

Retrieving a date from Firestore in Node.js

Fetching an image (Node.js)

Node.js: How to use kafka-node for fetching messages from beginning from a topic?

node fetching json from url

Fetching data from local .json file in react.js returns multiple errors

Document is not deleting from firestore

Firestore queried Document output 'undefined' and after few moments shows the correct data that is stored in Firestore in Node.js

firebase firestore get object/array from document - js

Firestore get all fields from a single document pure JS

How to read array document field from firebase firestore (React js)

How to sort data fetching from cloud firestore

Fetching List of Documents from Firestore in Swift

Fetching from firestore and Firebase functions timeout