本文整理汇总了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));
}