<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Knight</title>
    <description>The latest articles on DEV Community by David Knight (@lildxve).</description>
    <link>https://dev.to/lildxve</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F910033%2F88dc4880-6d30-4309-8176-4429e4a24865.png</url>
      <title>DEV Community: David Knight</title>
      <link>https://dev.to/lildxve</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lildxve"/>
    <language>en</language>
    <item>
      <title>Display a Key from Firebase Database</title>
      <dc:creator>David Knight</dc:creator>
      <pubDate>Tue, 16 Aug 2022 22:56:43 +0000</pubDate>
      <link>https://dev.to/lildxve/display-a-key-from-firebase-database-2om3</link>
      <guid>https://dev.to/lildxve/display-a-key-from-firebase-database-2om3</guid>
      <description>&lt;p&gt;Hello, I have a function where I am trying to display the user type when they're logged in. I currently have user name displaying but I'm not sure how to change my function to display the user's profile type. This is the error code I'm receiving and I have provided my code and a detailed screenshot of what I am trying to accomplish:&lt;/p&gt;

&lt;p&gt;This is the error I'm getting:&lt;/p&gt;

&lt;p&gt;Uncaught Error: child failed: path argument was an invalid path = "/Studiopick/studios[object HTMLParagraphElement]". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"&lt;br&gt;
    at na (validation.ts:374:11)&lt;br&gt;
    at ra (validation.ts:395:3)&lt;br&gt;
    at os (Reference_impl.ts:543:5)&lt;br&gt;
    at rs (Reference_impl.ts:483:31)&lt;br&gt;
    at Su.ref (Database.ts:102:24)&lt;br&gt;
    at getUserType (editprofile.js:74:25)&lt;br&gt;
    at editprofile.js:88:1&lt;br&gt;
This is my javascript code:&lt;/p&gt;

&lt;p&gt;// Initialize Firebase&lt;br&gt;
firebase.initializeApp(firebaseConfig);&lt;/p&gt;

&lt;p&gt;//Creating sets in database&lt;br&gt;
firebase.database().ref("/Studiopick/studios").child("users").update({&lt;/p&gt;

&lt;p&gt;});&lt;/p&gt;

&lt;p&gt;//Save information&lt;br&gt;
function save(){&lt;br&gt;
    studioName = document.getElementById("studioName").value;&lt;br&gt;
    email = document.getElementById("email").value;&lt;br&gt;
    firstName = document.getElementById("firstName").value;&lt;br&gt;
    lastName = document.getElementById("lastName").value;&lt;br&gt;
    address = document.getElementById("address").value;&lt;br&gt;
    country = document.getElementById("country").value;&lt;br&gt;
    state = document.getElementById("state").value;&lt;br&gt;
    city = document.getElementById("city").value;&lt;br&gt;
    zip = document.getElementById("zip").value;&lt;br&gt;
    phoneNumber = document.getElementById("phoneNumber").value;&lt;br&gt;
    firebase.database().ref("/Studiopick/studios/users").child(studioName).update({&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firstName : firstName,
lastName : lastName,
email : email,
address : address,
country : country,
state : state,
city : city,
zip : zip,
phoneNumber : phoneNumber,
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;//Get Information&lt;br&gt;
function getData(){&lt;br&gt;
    studioName = document.getElementById("studioName").value;&lt;br&gt;
    firebase.database().ref("/Studiopick/studios/users/" + studioName).on('value', function(snapshot){&lt;br&gt;
        snapshot.forEach(function(getProfile){&lt;br&gt;
           studioData = getProfile.val();&lt;br&gt;
           studio = getProfile.key;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       var email = studioData["email"];



       console.log("studio name: " + studio, "email: " + email);
       currentUser = "&amp;lt;h3&amp;gt;&amp;lt;strong&amp;gt;"+ studio + "&amp;lt;/strong&amp;gt;&amp;lt;/h3&amp;gt;";
       document.getElementById("profile-name").innerHTML = currentUser;
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
getData();&lt;/p&gt;

&lt;p&gt;//Get User Type&lt;br&gt;
function getUserType(){&lt;br&gt;
    profileType = document.getElementById("userType");&lt;br&gt;
    firebase.database().ref("/Studiopick/studios" + profileType).on('value', function(snapshot){&lt;br&gt;
        snapshot.forEach(function(getUserType){&lt;br&gt;
           typeData = getUserType.val();&lt;br&gt;
           type = getUserType.key;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       console.log("profile type: " + type);
       spAccType = "&amp;lt;p&amp;gt;"+ type + "&amp;lt;/p&amp;gt;";
       document.getElementById("userType").innerHTML = spAccType;
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
getUserType();&lt;br&gt;
What I'm trying to display from firebase:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ngn3UnBL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l80kx2vulpcd7s3mfoge.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ngn3UnBL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l80kx2vulpcd7s3mfoge.jpg" alt="Image description" width="778" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What I'm trying to achieve:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w4U3sRhA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4txp52bny688lpfryv66.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w4U3sRhA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4txp52bny688lpfryv66.jpg" alt="Image description" width="191" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
