In my angular2 app, I have service which send a get request to a url.
Here is my service:
import {Http} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import {Injectable} from '@angular/core';
import {Gallery} from './gallery';
@Injectable()
export class InstagramService{
constructor(private _http:Http){
}
getGallery(username: string) : Observable<Gallery> {
var result=this._http.get("https://www.instagram.com/"+username+"/media/").map(res => res.json());
console.log(result);
return result;
}
}
I have defined the return type as Observable<Gallery>, but it complains that:
A function whose declared type is neither 'void' nor 'any' must return a value
What is going wrong with this code?