I am new to Typescript and Angular2, and I am trying to create a promise by requesting http get, but the code below (exactly the return this.http.get(url) line return this.http.get(url) gives me an error:
error TS2346: Supplied parameters do not match any signature of call target.
In my service, I have an isLoggedIn method
isLoggedIn(): Promise<Object> { return this.http.get('/some/path') .map((res: Response) => res.json()) .toPromise(); }
Then I want to use it in my component, for example:
onInit() { this.login.isLoggedIn() .then((data: any) => { if (data.hasOwnProperty('status') && data.status === 401) { this.router.navigate(['/Login']); } else { this.router.navigate(['/Home']) } }); }
I looked at how to use the HTTP request and promise the correct path, but I did not find a good description.
source share