refresh() { this.http.refreshToken() .subscribe({ error: (err: any) => this.eh.handleError(err), complete: () => this.expiration = this.auth.getExpirationDate() }); }
get(data) { this.data = data; this.http.get('http://example.com/api/thing') .subscribe( data => this.result = data, err => console.log(err), () => console.log('Request Complete') ); }
get(url: string, args?: Object): Observable<any> { let params: URLSearchParams; if (args) { params = new URLSearchParams(); for (let key in args) { params.set(key, args[key]); } } let searchParams = {search: params}; return this.http.get(url, searchParams).map((res: any) => res.json()); }
post(url, data) { this.data = data; return this.http.post(url, this.data); }
get(meetId:string) { var url = this.actionUrl + (meetId ? '/' + meetId : ''); return this._http.get(url) .map(this.compose(Meet.from, this.extractData)) .catch(this.handleError); }
allPublic() { var url = this.actionUrl; return this._http.get(url + '?public=true') .map(this.compose(Meet.from, this.extractData)) .catch(this.handleError); }
allMine() { var url = this.actionUrl; return this._http.get(url) .map(this.compose(Meet.from, this.extractData)) .catch(this.handleError); }
put(url: string, data, options?: RequestOptionsArgs): Observable<any> { data = (typeof (data) === 'string') ? data : JSON.stringify(data); return this.http.put(url, data, options).map((res: any) => res.json()); }
ngOnInit() { this.user = this.auth.getPayload(); this.expiration = this.auth.getExpirationDate(); this.secret = this.http.get('/secret').map(response => response.text()); }