markdown guide
 

I added an thorough answer on SO, I'll add the TLDR version here:

This code wont work as expected

this.restApiOwner.getOwners().subscribe(Owners=> this.owners=Owners);
console.log(this.owners);

it should be this:

this.restApiOwner.getOwners().subscribe(Owners=> {
  this.owners=Owners;
  console.log(this.owners);
});

If the getOwners() call takes say 5 seconds to return, JS wont wait, and will keep executing code after it, only calling the subscribe callback once the data comes back. As I mentioned in the reply I recommend reading about how JS handles async stuff, as its key to the language.

 

In future, please don't just paste a link to Stack Overflow or the #help tag will be removed.

At least provide a short summary of what your issue is.

Thanks.

Classic DEV Post from Jan 16

What would you like to see on your DEV profile?

If we were to rethink the DEV profile, what would you like to see on it?

Acewings profile image

πŸ‘‹ Hey dev.to reader.

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❀️