import { ENV } from "../../config/env"; export const getPhotos = async (keyword: string, pre_page: number, token: string) => { try { const url = `${ENV.PEXELS_URL}/search?query=${keyword}&per_page=${pre_page}`; const response = await fetch(url, { headers: { Authorization: process.env.PEXELS_ACCESS_KEY as string, }, }) if (!response.ok) { return { status: 500, message: "An error occurred while getting the photos", token } } const data = await response.json(); return { data, token } } catch (error: any) { console.log("Error in getting photos:", error.message || error.toString()); return { status: 500, message: "An error occurred while getting the photos", token }; } }