Skip to content

Commit b157872

Browse files
committed
refactor: Simplify Unsplash image retrieval with optional chaining (#239)
1 parent 7980ff7 commit b157872

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/api/services/quotesService.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ async function getUnsplashImage(query) {
8080

8181
try {
8282
const response = await requestApi(unsplashUrl);
83-
if (response && response.urls && response.urls.regular) {
84-
return response.urls.regular;
85-
} else {
86-
return '';
87-
}
83+
return response?.urls?.regular ?? '';
8884
} catch (err) {
8985
console.error('Error fetching Unsplash image:', err);
9086
return '';

0 commit comments

Comments
 (0)