Maël.L
Maël.L

Reputation: 23

Firebase database set() error

I work with ReactJs and Firebase and I get an error message but all the work is apparently fine.

The issue :

export const CreateDbUser = (id, username, email) => {
  firebase.database().ref(`users/${id}`).set({
    username,
    email
  })
}

Here I create a database child to store different information about a user (it is just part of the info) and I get this error:

Object(...)(...) is undefined
TypeError: "Object(...)(...) is undefined"

but it all works in the real-time database

snapshot

I'd like to know why I get this error and how to resolve this because it will probably create a problem in the future. Thank for the help.

Upvotes: 0

Views: 244

Answers (1)

Barazu
Barazu

Reputation: 499

Unless username and email are objects (which I suppose they aren't), you are using set wrong.
Try this:

export const CreateDbUser = (id, username, email) => {
  firebase.database().ref(`users/${id}`).set({
    username: username,
    email: email
  })
}

Upvotes: 1

Related Questions