It appears that I'm facing a challenge with the small method; not sure if my brain is refusing to cooperate or what's going on.
async fetchContacts() {
await this.http.get('http://localhost:3000/contacts')
.subscribe(res => {
const newContacts = [].concat(res);
this.contacts = newContacts;
console.log(this.contacts);
});
console.log(this.contacts);
}
Expected outcome:
The second console.log should be triggered after the first one, and should display the same value as the first one.
Current situation:
The second console.log is appearing before the others.
Any ideas on how to solve this? Many thanks in advance.