penyesuaian service

This commit is contained in:
Fuzi_fauzia 2024-06-25 22:10:31 +07:00
parent 89203b9984
commit f36c8d0240
1 changed files with 11 additions and 8 deletions

View File

@ -10,19 +10,22 @@ const BASE_URL = 'https://kapi.absys.ninja/hemat';
export class DeviceService { export class DeviceService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
getDeviceData(id, category, status): Observable<any> { getDeviceData(id, category = "0", status = "0"): Observable<any> {
const endpoint = `/devices`; const endpoint = `/devices`;
const params = new URLSearchParams({ const params = new URLSearchParams({
page: "1", page: "1",
limit: "100", limit: "100",
building_id: id building_id: id,
category_id: category,
status_id: status,
room_id: "0"
}); });
if (category) { // if (category) {
params.append("category_id", category); // params.append("category_id", category);
} // }
if (status) { // if (status) {
params.append("status_id", status); // params.append("status_id", status);
} // }
const url = `${BASE_URL}${endpoint}?${params.toString()}`; const url = `${BASE_URL}${endpoint}?${params.toString()}`;
const headers = new HttpHeaders({ const headers = new HttpHeaders({
"Content-Type": "application/json", "Content-Type": "application/json",