Fix GET request parameter creation

This commit is contained in:
William Brawner 2020-02-19 05:14:03 +00:00
parent ae8615bec3
commit 518ec83708

View file

@ -80,7 +80,8 @@ export class TwigsHttpService implements TwigsService {
// Categories
getCategories(budgetId: number, count?: number): Observable<Category[]> {
const params = {
'budgetIds': [budgetId]
params: new HttpParams()
.set('budgetIds', `${budgetId}`)
};
return this.http.get<Category[]>(`${this.apiUrl}/categories`, Object.assign(params, this.options));
}
@ -109,13 +110,14 @@ export class TwigsHttpService implements TwigsService {
// Transactions
getTransactions(budgetId?: number, categoryId?: number, count?: number): Observable<Transaction[]> {
const params = {};
let httpParams = new HttpParams();
if (budgetId) {
params['budgetId'] = budgetId;
httpParams = httpParams.set('budgetId', `${budgetId}`);
}
if (categoryId) {
params['categoryId'] = categoryId;
httpParams = httpParams.set('categoryId', `${categoryId}`);
}
const params = { params: httpParams };
return this.http.get<Transaction[]>(`${this.apiUrl}/transactions`, Object.assign(params, this.options));
}