Error trying to fetch a Json


#1

Hi,

I am pretty new with Ionic2. I am trying to fetch a json but it s just undefine… Even with a copy paste from another thread…
What I am doing wrong?

import {HTTP_PROVIDERS} from 'angular2/http';
import {Injectable} from 'angular2/core';
import {Http, Response} from 'angular2/http';
import {Observable} from 'rxjs/Rx';


@Injectable()
export class Page1Service {   
    
     public dataDic : any;
    
    public constructor(private _http: Http) {}
    
    public IsPropertyExist(apermut:string):boolean {
    console.log("I am here");
    this.dictionary();
   
        
        return true;
    }
            
    
  
  public dictionary(){
 
 Observable.create(observer => {this._http.get('https://api.github.com/users/mralexgray/repos').map((response: Response) => response.json()
 .susbscribe(data=>{this.dataDic=data}));
 });
 console.log(this.dataDic);

}

    
}`

#2

Wut? It seems that you pretty new with js.

this._http.get('https://api.github.com/users/mralexgray/repos')
  .map((response: Response) => response.json())
  .susbscribe(data=>{
    this.dataDic=data;
    console.log(this.dataDic);
  });

#3

Thanks a lot. (just a typo your answer with suSbscribe).