本文整理匯總了TypeScript中angular2/http.Http類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Http類的具體用法?TypeScript Http怎麽用?TypeScript Http使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Http類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
getPlanets(): Observable<Planet[]> {
return this.http.get('http://swapi.co/api/planets/')
.map(this.extractData)
.catch(this.handleError)
}
示例2:
getComentariosEvento(id:number){
return this.http.get(URL+id)
.map(response => response.json())
.catch(error => this.handleError(error));
}
示例3: getBooks
getBooks(): Observable<any> {
return this.http.get(this.baseUrl).map(response => response.json());
}
示例4:
get_req(url: string, options?: Object) : any {
var url = this.query(url, options);
return this.http.get(url)
.map((res: Response) => res.json());
}
示例5: insert
insert(doc) : any {
return this.http.post("/contacts", JSON.stringify(doc))
.map((res: Response) => res.json());
}
示例6:
GetMatches()
{
return this.http.get('/rest/match');
}
示例7: getResume
getResume(){
return this._http.get("http://api.steve-botello.com/resume").map(r => r.json())
}
示例8: updateItem
updateItem(item:Item) {
this.http.put(`${BASE_URL}${item.id}`, JSON.stringify(item), HEADER)
.subscribe(action => this.store.dispatch({type: 'UPDATE_ITEM', payload: item}));
}
示例9: deleteItem
deleteItem(item:Item) {
this.http.delete(`${BASE_URL}${item.id}`)
.subscribe(action => this.store.dispatch({type: 'DELETE_ITEM', payload: item}));
}
示例10: loadAllItems
loadAllItems() {
this.http.get(BASE_URL)
.map(res => res.json())
.map(payload => ({type: 'ADD_ITEMS', payload}))
.subscribe(action => this.store.dispatch(action));
}