[英]How can I send values in the body in the HTTP GET request in Angular?
我在我的服務中寫了以下 function:
/**
* Get all data
* @param sendSelectedValues string
*/
getAllActPlanBalanceYearData(sendSelectedValues: any): Observable<any> {
const url = `/yearlyvalues/act-and-plan-balance`;
return this.http.get<any>(`${environment.baseUrl}` + url);
}
我現在想在正文中發送 sendSelectedValues。 在帖子和補丁中很容易做到。 它是如何在 get 中工作的? 不幸的是,我還沒有找到解決方案....你能幫幫我嗎?
您可以使用 queryParam 執行此操作:
getAllActPlanBalanceYearData(sendSelectedValues: string): Observable<any> {
const params = new HttpParams()
.set('values', sendSelectedValues);
const url = `/yearlyvalues/act-and-plan-balance`;
return this.http.get<any>(`${environment.baseUrl}` + url, { params });
}
你不能在體內這樣做
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.