Skip to content

Question : API usage - how replace a prototype with returned string ? #3

@olga-bouin

Description

@olga-bouin

When I console.log the result in subscribe it's ok, but the value of my variable jokes isn't updated.

Screenshot from 2021-11-08 15-01-11

I also wonder why second console.log is issued before the first one. In my code it's in this order :

  getNewJoke(): void {
    this.chuckService.getJokes().subscribe({next(data) {this.jokes = [{randomJoke: data.value}];
                                                        console.log('joke in subscribe -----------------------', data.value); }}) ;
    console.log('joke outside subscribe -----------------------', this.jokes);
  }

Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions