Corrige base da API de notificações
This commit is contained in:
parent
29348e54ae
commit
cce651eef9
|
|
@ -23,15 +23,18 @@ export type NotificationDto = {
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class NotificationsService {
|
export class NotificationsService {
|
||||||
private readonly baseUrl = `${environment.apiUrl}/notifications`;
|
private readonly baseApi: string;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {
|
||||||
|
const raw = (environment.apiUrl || '').replace(/\/+$/, '');
|
||||||
|
this.baseApi = raw.toLowerCase().endsWith('/api') ? raw : `${raw}/api`;
|
||||||
|
}
|
||||||
|
|
||||||
list(): Observable<NotificationDto[]> {
|
list(): Observable<NotificationDto[]> {
|
||||||
return this.http.get<NotificationDto[]>(this.baseUrl);
|
return this.http.get<NotificationDto[]>(`${this.baseApi}/notifications`);
|
||||||
}
|
}
|
||||||
|
|
||||||
markAsRead(id: string): Observable<void> {
|
markAsRead(id: string): Observable<void> {
|
||||||
return this.http.patch<void>(`${this.baseUrl}/${id}/read`, {});
|
return this.http.patch<void>(`${this.baseApi}/notifications/${id}/read`, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue