Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

519
Vistas
FirebaseError: [code=invalid-argument]: Function setDoc() called with invalid data

I am using Firebase SDK's within Node-red (as specified in NPM docs they can be used for IoT devices with NODE.js).

  • I can use all of the CRUD methods with Firebase RealtimeDatabase.
  • With Firebase Firestore I can only use READ and DELETE functionality.
  • SET and UPDATE results in weird errors that I couldn't find answers anywhere on the internet.

I am importing Firebase SDK's through require() inside settiings.js and functionGlobalContext so I can access them in Node-red functions:

functionGlobalContext: {
    firebase: require('firebase/app'),
    firebaseDatabase: require('firebase/database'),
    firebaseFirestore: require('firebase/firestore'),
    // os:require('os'),
    // jfive:require("johnny-five"),
    // j5board:require("johnny-five").Board({repl:false})
},

First I initialize my whole Firebase project with this code (and everything initializes fine without errors):

//Load data from Global contexta
const firebase = global.get('firebase');
const firebaseDatabase = global.get('firebaseDatabase');
const firebaseFirestore = global.get('firebaseFirestore');


const firebaseConfig = {
     //my Firebase credentials
};

//Set up Firebase
const app = firebase.initializeApp(firebaseConfig);
const database = firebaseDatabase.getDatabase();
const firestore = firebaseFirestore.getFirestore();

//Save the database reference to Global context
global.set('app', app);
global.set('database', database);
global.set('firestore', firestore);

And here I am trying basic SET operation with Firestore:

const ft = global.get('firebaseFirestore');
const firestore = global.get('firestore');

const frankDocRef = ft.doc(firestore, "users", "frank");
await ft.setDoc(frankDocRef, {
    name: "Frank",
    age: 12
});

Unfortunately even though this code is ctrl+c ctrl+v from Firestore docs I get this error:

"FirebaseError: [code=invalid-argument]: Function setDoc() called with invalid data. Data must be an object, but it was: a custom Object object (found in document users/frank)"
  • When I use the same code inside a web app everything works fine.
  • There has to be something going on under the hood with Node-red
  • I tried creating the object using various methods and all of them resulted in the same error.

Does anybody have any idea what could be going wrong here?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda