1

I get an object from my code

       const username = await firebase
        .database()
        .ref("users/" + authUser + "/name")
        .once("value")
        .then(function(snapshot) {
          return snapshot;
        });

Its value is "testname". Its logging everything correct to console. But if I try to reuse my username for example in

      const url = `https://url.com/users/${username}/${authUser}/posts.json?auth=${token}`;

I get in my console.log

https://url.com/users/[object Object]/...

I am pretty new to firebase and JS but I think I have to transform my object to a string? How to achive this?

Brydawg
  • 79
  • 6

1 Answers1

1

Use the following to convert your object to a string

JSON.stringify(object)
joy08
  • 9,004
  • 8
  • 38
  • 73