Files
classroomio/apps/dashboard/src/lib/features/ui/upload-widget/utils.ts
T

22 lines
601 B
TypeScript
Raw Normal View History

2025-01-09 01:30:01 +01:00
import { getAccessToken } from '$lib/utils/functions/supabase';
2023-10-05 09:22:39 +00:00
export async function queryUnsplash(searchQuery: string) {
try {
const response = await fetch('/api/unsplash', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
2025-01-09 01:30:01 +01:00
Authorization: await getAccessToken()
2023-10-05 09:22:39 +00:00
},
body: JSON.stringify({ searchQuery })
});
if (!response.ok) {
throw new Error(await response.text());
}
const result = await response.json();
return result.photos;
} catch (error) {
console.error('Error sending fetch request', error);
}
2023-11-25 21:56:02 +00:00
}