addRider(rider: Rider): Observable<any> { return this.http .post(this.ridersUrl, rider) .map(res => res.json()); }
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) }
private post(hero: Hero): Promise<Hero> { let headers = new Headers({ 'Content-Type' : 'application/json' }); return this.http.post(this.heroesUrl, JSON.stringify(hero), {headers: headers}) .toPromise() .then(res => res.json().data) .catch(this.handleError); }
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); } }
constructor(private http: Http ) { this.myDate = new Date(); let URI = environment.api_url || `/api/games/`; http.get(URI) .map(res => res.json()) .subscribe(games => this.games = games); }
public ngOnInit() { this.http.get("http://localhost:3000/api/getAll") .map(result => result.json()) .subscribe(results => { this.people = results; }, error => { console.error(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); }); }
getArticles(): Promise<Article[]> { return this.http.get(this.articlesUrl) .toPromise() .then(response => { this.articles = response.json() as Article[]; return this.articles; }) .catch(this.handleError); }
public getJSON() { return this.http .get(this._url) .map((response: Response) => response.json()); }
authenticate(o: Object): Observable<any> { return this.http .post(`${this.authUrl}/token`, o) .map(res => res.json()); }
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) }
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); }); }
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) }