Skip to content

Commit

Permalink
Add extra safeguard agains category fetching request
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Feb 28, 2023
1 parent e9bb9de commit cfe1680
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ export function useMediaCategories( rootClientId ) {
if ( category.isExternalResource ) {
return [ category.name, true ];
}
const results = await category.fetch( { per_page: 1 } );
let results = [];
try {
results = await category.fetch( {
per_page: 1,
} );
} catch ( e ) {
// If the request fails, we shallow the error and just don't show
// the category, in order to not break the media tab.
}
return [ category.name, !! results.length ];
} )
)
Expand Down

0 comments on commit cfe1680

Please sign in to comment.