-2
what am I doing wrong? the variable test is not being fed, always Undefined
result.data is ok, the api is working and the query tbm, the problem is the variable test that always this Undefined
Angular+Apollo-graphql
getUser(data: String): Observable<any> {
let test: any
this.apollo.query({ query: gql`${data}` }).subscribe(result => {
test = result.data
})
console.log(test)//<< sempre retorna undefined
return test
}
what I’m doing wrong? Just look at the sequence that Javascript runs and know what it is
assíncrono
!– LeAndrade