1 回答

TA贡献1836条经验 获得超4个赞
您可以使用HttpParamsbuilder 通过链接append方法自动解析您的参数。并且使用一些减速器,您可以在 httpParams 中提供数组值
import { HttpParams } from '@angular/common/http';
//Whatever...
getInvestors(vehicules: number[], page: number, maxPerPage: number): Promise<MelodiiaCollectionResponse> {
const params = vehicules.reduce(
(previous, vehicule, index) => previous.append(`vehicule[${index}]`, vehicule.toString()),
new HttpParams()
)
.append('max_per_page', maxPerPage.toString())
.append('page', page.toString())
return this.http.get<MelodiiaCollectionResponse>(`${environment.httpdBackHost}/investisseurs`, {
params,
}).toPromise();
}
- 1 回答
- 0 关注
- 152 浏览
添加回答
举报