1

I'm all the time learning. My question is: why this:

let user = {
   firstname: '',
   secondname: ''
}

let hz = new Horizon({host: "164.132.192.28:3100"});
let table = hz('users');
hz.connect();
table.find(1).fetch().subscribe((value) => { 
   user = {
     firstname: value.firstname,
     secondname: value.secondname
   }

   //OR: 
   user.firstname = value.firstname;
   user.secondname = value.secondname;

});

console.log(user);

gives me this:

...

And why I can't get value?:

console.log(user.firstname);
//prints nothing

My third question: how to just save the results from query into an object and use it outside the query? If I use 'return' keyword then results are similar. I know it's a newbie question but I'm really struggling with this... Can someone help me?

4

1 に答える 1