當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。