NOTE: The problem is definetly the ionViewDidLoad() not being executed cause the http.get does get an observable. I'm trying to get the observable when executing a request in order to get its json response later but I don't get an error, and nothing is displayed in the browser's console either. I don't know why it does not return anything.
I have tried many urls and checked many times the imports. console.log not pasting the data home.page.ts
import { ServicioService } from '../servicio.service';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
...
ionViewDidLoad(){
const hola = this.servicio.goWiki(this.userInput).
subscribe((response) => {
console.log(response);
});
}
servicio.service.ts
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class ServicioService {
constructor(public http: HttpClient) {
console.log('goin!');
}
goWiki(userInput): Observable<any>{
return this.http.get('https://www.reddit.com/r/gifs/top/.json?limit=105sort=hot');
}
app.module.ts
import { ServicioService } from './servicio.service';
import { HttpClientModule } from '@angular/common/http';
imports: [HttpClientModule, BrowserModule, IonicModule.forRoot(), AppRoutingModule, ComponentesModule],
providers: [
ServicioService,...
I just hope to get an observable to be able to read it and extract specific data from it.
ionViewDidLoad ()
is called ? Please check this post: [stackoverflow.com/questions/40339833/… not being called) – Thierry Falvo Jul 2 '19 at 17:04