Estou tentando atribuir dados de uma solicitação GET a uma variável. Entendo que uma solicitação GET HttpClient retorna um Observable<any>
que deve ser assinado. O seguinte funciona, ele imprime os dados corretos (um objeto Json):
this.get("").subscribe(response => {console.log(response)});
Entretanto, quando tento atribuir uma resposta a uma variável:
let raw; //have also tried var as I thought it might be related to scope?
this.get("").subscribe(response => {raw = response});
console.log(raw) //returns undefined
let raw = this.get("").subscribe(response => response); //have also tried => response.data with same result
console.log(raw) //returns a weird object that I assume is the observer?
Qual é a melhor maneira de fazer isso?