1
1
import { Injectable } from '@angular/core' ;
2
- import { HttpClient } from '@angular/common/http' ;
2
+ import { HttpClient , HttpParams } from '@angular/common/http' ;
3
3
import { Observable } from 'rxjs' ;
4
4
import { catchError , finalize , map , retry } from 'rxjs/operators' ;
5
- import { EntityService } from '@ngx-starter-kit/shared' ;
5
+ import { EntityService , IPagination } from '@ngx-starter-kit/shared' ;
6
6
import { environment } from '@env/environment' ;
7
7
import { AppNotification } from '@ngx-starter-kit/notifications' ;
8
8
@@ -19,13 +19,14 @@ export class NotificationService extends EntityService<AppNotification> {
19
19
}
20
20
21
21
getAll ( ) : Observable < AppNotification [ ] > {
22
+ const params = new HttpParams ( ) . set ( 'order' , 'ASC' ) . set ( 'read' , 'false' ) ;
22
23
this . loadingSubject . next ( true ) ;
23
- return this . httpClient . get < [ AppNotification [ ] , number ] > ( `${ this . baseUrl } /${ this . entityPath } ` ) . pipe (
24
+ return this . httpClient . get < IPagination < AppNotification > > ( `${ this . baseUrl } /${ this . entityPath } ` , { params } ) . pipe (
24
25
retry ( 3 ) , // retry a failed request up to 3 times
25
26
catchError ( this . handleError ) ,
26
27
finalize ( ( ) => this . loadingSubject . next ( false ) ) ,
27
28
// return without count
28
- map ( data => data [ 0 ] ) ,
29
+ map ( data => data . items ) ,
29
30
) ;
30
31
}
31
32
0 commit comments