Corrige base da API de notificações

This commit is contained in:
Eduardo Lopes 2026-01-22 16:06:41 -03:00
parent 29348e54ae
commit cce651eef9
1 changed files with 7 additions and 4 deletions

View File

@ -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`, {});
} }
} }