Im trying to get a list from github api but I'm only receiving values when I call the service for the second time.
I have this function on the component
repos;
showRepos(userLogin) {
this.buscaService.getRepos(userLogin).subscribe(
repo => this.repos = repo
)
console.log('this repos', this.repos);
}
and on the service I have a simple http.get
:
getRepos(user) {
return this.http.get('https://api.github.com/users/' + user + '/repos');
}
The first time I call the service it show that this.repos is undefined, but when I call it for the second time it shows me the array. How can I make it print on the first time?