Skip to content

Commit

Permalink
adding error handling to the requests of sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexm3133 committed Dec 17, 2023
1 parent c46b569 commit 9152099
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/app/components/refuge-info/refuge-info.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export class RefugeInfoComponent implements OnInit {
constructor(private http: HttpClient) {}

ngOnInit() {
if (!this.refuge || !this.refuge.id) {
console.error('Refuge or refuge.id is undefined');
this.sensorStatus = 'error';
return;
}

this.http.get<any>(`${sensorsApiUrl}/refugio/${this.refuge.id}`)
.subscribe({
next: (data) => {
Expand All @@ -29,6 +35,7 @@ export class RefugeInfoComponent implements OnInit {
}
});
}


isActivityRecent(lastActivity: string): boolean {
const activityDate = new Date(lastActivity);
Expand Down

0 comments on commit 9152099

Please sign in to comment.