Saving user information (userName) in Firebase with Angular 2: A step-by-step guide

Does anyone know how I can save a user's UserName in Firebase and retrieve it when they log in? I'm struggling to figure it out. Can someone help me with what code I need to add?


  signUp(userEmail , userPassword){
    firebase.auth().createUserWithEmailAndPassword(userEmail, userPassword).catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // ...
    });

 signIn(userEmail , userPassword){
firebase.auth().signInWithEmailAndPassword(userEmail, userPassword).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

I appreciate any assistance on this matter. Thank you.

Answer №1

I successfully managed to tackle this issue. Simply string together functions in the following manner:

 firebase.auth().createUserWithEmailAndPassword(userEmail, userPassword).then(function (result) {

  firebase.database().ref('/users/' + result.uid).set({
    username: 'someOne',
    email:userEmail,
  });

  console.log(result);
}).catch(function (error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

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

repeated firing of keydown event in ReactJS

Having an issue with adding an event listener and checking if it's level 1. When I press the space key once, it seems to fire more than 50 times. Any assistance would be greatly appreciated. document.addEventListener("keyup", function(e) { if(l ...

using database URL as an AJAX parameter

I am currently working on a Python CherryPy controller that needs to validate a database URL by attempting a connection. However, I am facing challenges with passing the parameter to the method. Below is my AJAX call: $.ajax({ async: false, ty ...

Utilizing Node.js to handle incoming HTTP requests

As I navigate my way through learning about node and javascript, I am facing an obstacle in saving the data from an HTTP request into an object that I can access beyond the scope of the request. My goal is to iterate through another object in order to ret ...

Customize the ID key in Restangular

When using Restangular, default behavior for PUT/PATCH/POST operations is to use the id of an item as the primary key. But what if you want to use a custom key like a slug or number instead? // GET to /users Users.getList().then(function(users) { var ...

Retrieve the code from the Firebase console that was previously deployed

I recently set up Firebase functions using Node.js and deployed the code on Firebase. One of the functions was designed to send an email whenever a new user is created. Unfortunately, I seem to have misplaced the code. Is there any way we can retrieve th ...

Incorporate a fresh module into an Angular application

Currently, I am working on my application and have the following setup: var testApp = angular.module('testApp', ['ngRoute']); I recently installed a new module but haven't fully integrated it into my app yet. Can you guide me on ...

Selecting databases and tables on the fly in the pg-promise API

Instead of using a hardcoded initial connection object, the pg-promise API suggests creating a dynamic connection object like this: var pgp = require('pg-promise')(); const mysqlcon = `postgres://${process.env.DB_USER}:${process.env.DB_PASSWORD}@ ...

Using outdated props for dynamically rendered list in React/Redux

When rendering content by mapping over an array to display items individually, everything works fine until an onClick event is implemented. The onClick event uses the current index from the store to push content into an array, but for some reason it return ...

How come my object is iterating from last to first in the for loop?

I need help understanding arrays. Here is my data: And here is my for loop: for (var data in statInfo["segment"][0]) { console.log(data) } After running the code, I got this result: The printed data is: segment5 segment4 segment3 segment2 se ...

Is TypeScript capable of comprehending Svelte components?

When it comes to Svelte, the final output is native JavaScript classes, which TypeScript can understand. However, before TypeScript can recognize Svelte components, they must first be compiled from their initial .html form. This can lead to a 'cannot ...

Error: The function $(...).maxlength is not recognized - error in the maxlength plugin counter

I have been attempting to implement the JQuery maxlength() function in a <textarea>, but I keep encountering an error in the firefox console. This is the code snippet: <script type="text/JavaScript"> $(function () { // some jquery ...

Error: Discord Bot is unable to locate module './commands/ban.js'

Here is my code snippet: require('dotenv').config(); const fs = require('fs'); const Discord = require('discord.js'); const { error } = require('console'); const client = new Discord.Client(); client.commands = new D ...

Using jQuery's .css() method on elements that are iterated over will not yield the

How can I change the style of a specific input tag if its attribute name matches the value of a select tag? I keep getting an error stating elem.css is not a function. Any help or solutions would be greatly appreciated. const calcTyp = $('#calcTyp&ap ...

JavaScript is currently being loaded but is not being executed in Rails 3.1

Within my application layout file, there is an external JavaScript file with multiple lines of code that ultimately executes a function like BooManager.init(). Seems simple enough... However, the issue arises when the internal code in this JavaScript file ...

Utilizing RXJS in Angular to pull information from numerous services within a single component

There are two services, ser1 and ser2. getdata1() { this.http.get<{message:string,Data1:any}>('http://localhost:3000/api/1') .pipe(map((data1)=>{ return Data1.Data1.map(data=>{ return { id: d ...

Can you explain the significance of the 'X-Bandwidth-Est 3' error message that states, "Refused to get unsafe header"?

I'm currently facing an issue with all the websites I am working on where I keep encountering the following error: Refused to get unsafe header "X-Bandwidth-Est 3" in base.js. This error seems to be related to a YouTube file named base.js, but after ...

JavaScript has limitations when it comes to incrementing values by one inside a label

When dynamically adding fields, I want to display either an input field or a label with a field number. For example, if a new field is added and it appears as the second field, it should be labeled as 2. $(function() { /* Increment values for each newly ...

Performing XMLHttpRequests and ajax requests inside a foreach loop

I am facing a issue with echoing the decoded array using var_dump. Each time I click the button, a unique xmlhttprequest and ajax call should get executed for every row. However, in reality, the ajax doesn't work as expected. Upon examining the source ...

A guide to sending parameters in the URL body using TypeScript for a REST API on the Ionic framework

As a novice in Ionic and TypeScript, I am facing an issue with accessing an API. The API can only be accessed using the POST method with parameters passed in the body for security reasons. I need to retrieve JSON data from this API but I'm unsure how ...

Is there a way to programmatically detach a jQuery function that is currently attached?

Within the $.ready() method, a click function is defined for $("#btnClk"). See code snippet below: $(document).ready(function(){ $("#btnClk").click(function(clkevent){ //Performing a task here clkevent.preventDefault(); }); }); N ...