getStrongAlcoholReports(selectedItems?): Observable<ReportModel> {
let selecteditemstest = [];
let apiParams;
if (selectedItems) {
for (let code of selectedItems) {
for (let codesarr of code.codes) {
selecteditemstest.push(codesarr);
apiParams = selecteditemstest.join('&codes=');
}
}
return this.http.get<ReportModel>(this.listOfStrongAlcoholReports, { params: { codes: apiParams } });
} else {
return this.http.get<ReportModel>(this.listOfStrongAlcoholReports, { params: { codes: '200&codes=262' } });
}
}
const params = codes.reduce(
(acc, code) => acc.append('codes', `${code}`),
new HttpParams(),
);
this.http.get<ReportModel>(this.listOfStrongAlcoholReports, { params });
codes
это [200, 262 ]
HttpParams
const params = new HttpParams({
fromObject: { codes: codes.map(String) }
});