当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript http.HttpClient类代码示例

本文整理汇总了TypeScript中@angular/common/http.HttpClient的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpClient类的具体用法?TypeScript HttpClient怎么用?TypeScript HttpClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HttpClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getBooksAndMovies

 // Uses Observable.forkJoin() to run multiple concurrent http.get() requests.
 // The entire operation will result in an error state if any single request fails.
 getBooksAndMovies() {
     return Observable.forkJoin(
     this.http.get('/api/books'),
     this.http.get('/api/movies')
     );
 }
开发者ID:anjalisankar,项目名称:angular5-httpcall,代码行数:8,代码来源:demo.service.ts

示例2: getScript

 getScript(scriptId: number) {
   return this.http.get<Script>(`${InteractiveExplorerConfig.API_URL}/scripts/${scriptId}`);
 }
开发者ID:our-city-app,项目名称:plugin-interactive-explorer,代码行数:3,代码来源:scripts.service.ts

示例3: updateFood

 // send a PUT request to the API to update a data object
 updateFood(food) {
     let body = JSON.stringify(food);
     return this.http.put('/api/food/' + food.id, body, httpOptions);
 }
开发者ID:anjalisankar,项目名称:angular5-httpcall,代码行数:5,代码来源:demo.service.ts

示例4: getHero

 // This get-by-id will 404 when id not found
 getHero(id: number): Observable<Hero> {
   const url = `${this.heroesUrl}/${id}`;
   return this.http.get<Hero>(url).pipe(
     catchError(this.handleError)
   );
 }
开发者ID:angular,项目名称:in-memory-web-api,代码行数:7,代码来源:http-client-hero.service.ts

示例5: findAll

 findAll(): Observable<GatewayRoute[]> {
     return this.http.get<GatewayRoute[]>(SERVER_API_URL + 'api/gateway/routes/');
 }
开发者ID:Doha2012,项目名称:tutorials,代码行数:3,代码来源:gateway-routes.service.ts

示例6: postNewContact

 postNewContact(contactData: Contact): Observable<Contact> {
   return this.http.post<Contact>(`${environment.backend}/api/contact/`, contactData);
 }
开发者ID:hasadna,项目名称:open_pension,代码行数:3,代码来源:contact.service.ts

示例7: create

 public create(user: User): Observable<User> {
   return this.httpClient.post<User>("/api/users", user, {
     headers: { "Authorization": "Bearer " + localStorage.getItem("access_token") }
   });
 }
开发者ID:lexdevel,项目名称:MicroCRM,代码行数:5,代码来源:user.service.ts

示例8: deleteLetters

 deleteLetters(id) {
   return this._http.delete(`https://test-api.javascript.ru/v1/ssumatokhin/letters/${id}`, { responseType: 'text' });
 }
开发者ID:Serdji,项目名称:angularDZ,代码行数:3,代码来源:letters.service.ts

示例9: getLetter

 getLetter(id) {
   return this._http.get(`https://test-api.javascript.ru/v1/ssumatokhin/letters/${id}`);
 }
开发者ID:Serdji,项目名称:angularDZ,代码行数:3,代码来源:letters.service.ts

示例10: runFunction

 runFunction(parameters: RunScript) {
   return this.http.post<RunResult>(`${InteractiveExplorerConfig.API_URL}/scripts/${parameters.id}`, parameters);
 }
开发者ID:our-city-app,项目名称:plugin-interactive-explorer,代码行数:3,代码来源:scripts.service.ts


注:本文中的@angular/common/http.HttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。