Advertisement
elliottchong

unsplash.ts

Aug 20th, 2023
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. export const getUnsplashImage = async (query: string) => {
  2. const imageResponseRaw = await fetch(
  3. `https://api.unsplash.com/search/photos?per_page=1&query=${query}&client_id=${process.env.UNSPLASH_API_KEY}`
  4. );
  5. const imageResponse = await imageResponseRaw.json();
  6. return imageResponse.results[0].urls.small_s3;
  7. };
  8.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement