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.

 

ah ok am sorry new here i will make sure to do that in the future ^

Classic DEV Post from Jun 5

Dear Developers, What's Your Work/Home Setup Like?

Acewings profile image

dev.to is where software developers stay in the loop and avoid career stagnation.

Sign up (for free)