-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Ant-Shell/fix/deploy-related-issues
Fix: Deploy Related Issues
- Loading branch information
Showing
2 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { createClient, Photos } from 'pexels'; | ||
|
||
const API_KEY = import.meta.env.VITE_APP_API_KEY; | ||
const client = createClient(API_KEY); | ||
|
||
const getImages = async (): Promise<Photos> => { | ||
const getImages = async () => { | ||
try { | ||
const response = await client.photos.curated({ per_page: 8 }); | ||
if ('photos' in response) { | ||
return response as Photos; | ||
} else { | ||
const errorMessage = response | ||
throw new Error(errorMessage.error); | ||
const response = await fetch("https://api.pexels.com/v1/curated?per_page=8", { | ||
headers: { | ||
Authorization: API_KEY | ||
} | ||
}) | ||
if (!response.ok) { | ||
throw new Error(response.statusText) | ||
} | ||
const data = await response.json() | ||
return data | ||
|
||
} catch (error) { | ||
console.error("Failed to fetch curated photos:", error); | ||
throw error; | ||
console.log(error) | ||
throw error | ||
} | ||
}; | ||
} | ||
|
||
export { getImages }; |