authenticate(o: Object): Observable<any> { return this.http .post(`${this.authUrl}/token`, o) .map(res => res.json()); }
getRepos() { if (this.userName) { return this._http.get('http://api.github.com/users/' + this.userName + '/repos?client_id=' + this.clientId + '&client_secret=' + this.clientSecret) .map(res => res.json()) .catch(this.handleError); } }
addSongToMyList (id:string, songId:string): Promise<void>{ return this.http.post('addSongToMyList', {id:id, songId:songId}) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
private extractData(res: Response) { try{ let body = res.json() return body.result || body } catch (error) { console.error('Error extracting api data: ' + error ) return ['Error'] } }
public save() { let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); this.http.post("http://localhost:3000/api/save", JSON.stringify(this.person), options) .map(result => result.json()) .subscribe(results => { this.location.back(); }, error => { console.error(error); }); }
public ngOnInit() { this.http.get("http://localhost:3000/api/getAll") .map(result => result.json()) .subscribe(results => { this.people = results; }, error => { console.error(error); }); }
public getJSON() { return this.http .get(this._url) .map((response: Response) => response.json()); }
checkShareRequest(id : string): Promise<object>{ return this.http.get('checkShareRequest?id=' + id) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
addRider(rider: Rider): Observable<any> { return this.http .post(this.ridersUrl, rider) .map(res => res.json()); }
public save() { let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); this.http.post("http://localhost:3000/api/save", JSON.stringify(this.person), options) .map(result => result.json()) .subscribe(results => { this.location.back(); }, error => { console.error(error); }); }
token(id : string, filename: string): Promise<object>{ return this.http.post('token', {id : id, filename:filename}) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
apply (username:string, password:string, interest:string): Promise<string>{ return this.http.post('apply', {username:username, password:password, interest:interest}) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
searchSongs(songname : string): Promise<object>{ return this.http.get('searchSongs?songname=' + songname) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
downloadSong(url : string): Promise<string>{ return this.http.get('downloadSong?url=' + url) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }
searchFriends(username : string, myname:string): Promise<object>{ return this.http.get('searchFriends?username=' + username + "&myname=" + myname) .toPromise() .then(response => response.json() as any) .catch(this.handleError) }