Skip to content

Commit

Permalink
refactor: Simplify Unsplash image retrieval with optional chaining (#239
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Satorino01 committed Feb 16, 2025
1 parent 7980ff7 commit b157872
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/api/services/quotesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ async function getUnsplashImage(query) {

try {
const response = await requestApi(unsplashUrl);
if (response && response.urls && response.urls.regular) {
return response.urls.regular;
} else {
return '';
}
return response?.urls?.regular ?? '';
} catch (err) {
console.error('Error fetching Unsplash image:', err);
return '';
Expand Down

0 comments on commit b157872

Please sign in to comment.