File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ const REQUEST_PARAMS = {
77 per_page : 0
88} ;
99
10+ const REQUEST_PARAMS_GETALL = {
11+ per_page : 10
12+ } ;
13+
1014/**
1115 * Base class for all Core Data services. This class is responsible for fetching data from either the Astro
1216 * content layer or directly from Core Data.
@@ -39,8 +43,19 @@ class Base {
3943 const entries = await getCollection ( this . name ) ;
4044 records = _ . map ( entries , ( entry ) => entry . data ) ;
4145 } else {
42- const response = await this . service . fetchAll ( REQUEST_PARAMS ) ;
43- records = response [ this . name ] ;
46+ records = [ ] ;
47+ let pages = 1 ;
48+ for ( let page = 1 ; page <= pages ; page ++ ) {
49+ try {
50+ const response = await this . service . fetchAll ( _ . extend ( REQUEST_PARAMS_GETALL , { page } ) ) ;
51+ if ( response . list ?. pages > pages ) {
52+ pages = response . list ?. pages ;
53+ }
54+ records = [ ...records , ...response [ this . name ] ] ;
55+ } catch ( error ) {
56+ console . log ( error ) ;
57+ }
58+ }
4459 }
4560
4661 return {
You can’t perform that action at this time.
0 commit comments