File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,13 +39,13 @@ class APIClient {
3939 const url = prefix ? `/api/pages?prefix=${ encodeURIComponent ( prefix ) } ` : '/api/pages' ;
4040 const res = await fetch ( url ) ;
4141 if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
42- return res . json ( ) ;
42+ return ( await res . json ( ) ) || [ ] ;
4343 }
4444
4545 async searchPages ( query : string , limit = 20 ) : Promise < SearchResult [ ] > {
4646 const res = await fetch ( `/api/search?q=${ encodeURIComponent ( query ) } &limit=${ limit } ` ) ;
4747 if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
48- return res . json ( ) ;
48+ return ( await res . json ( ) ) || [ ] ;
4949 }
5050
5151 async createPage ( path : string , content : string ) : Promise < void > {
@@ -74,7 +74,7 @@ class APIClient {
7474 async getBacklinks ( path : string ) : Promise < string [ ] > {
7575 const res = await fetch ( `/api/backlinks/${ path } ` ) ;
7676 if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
77- return res . json ( ) ;
77+ return ( await res . json ( ) ) || [ ] ;
7878 }
7979
8080 async allLinks ( ) : Promise < Link [ ] > {
You can’t perform that action at this time.
0 commit comments