本文整理匯總了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')
);
}
示例2: getScript
getScript(scriptId: number) {
return this.http.get<Script>(`${InteractiveExplorerConfig.API_URL}/scripts/${scriptId}`);
}
示例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);
}
示例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)
);
}
示例5: findAll
findAll(): Observable<GatewayRoute[]> {
return this.http.get<GatewayRoute[]>(SERVER_API_URL + 'api/gateway/routes/');
}
示例6: postNewContact
postNewContact(contactData: Contact): Observable<Contact> {
return this.http.post<Contact>(`${environment.backend}/api/contact/`, contactData);
}
示例7: create
public create(user: User): Observable<User> {
return this.httpClient.post<User>("/api/users", user, {
headers: { "Authorization": "Bearer " + localStorage.getItem("access_token") }
});
}
示例8: deleteLetters
deleteLetters(id) {
return this._http.delete(`https://test-api.javascript.ru/v1/ssumatokhin/letters/${id}`, { responseType: 'text' });
}
示例9: getLetter
getLetter(id) {
return this._http.get(`https://test-api.javascript.ru/v1/ssumatokhin/letters/${id}`);
}
示例10: runFunction
runFunction(parameters: RunScript) {
return this.http.post<RunResult>(`${InteractiveExplorerConfig.API_URL}/scripts/${parameters.id}`, parameters);
}