Accessing the unsplash image library using the API You should regsiter with the website who ll give you a key similar to the one below which you can use to access search for images const apiUrl https api unsplash com search photos per_page 24 query const apikey Client ID 1ff567feea79565eafd82a37c3e34e5dacdbb411a117a9bec0bc20ffbd1a8612 fetch apiUrl people headers Authorization apikey then resp get as a txt just to see what s getting returned return resp text then data limit to just 2000 chars to see the tag names console log data substring 0 2000 console log ready Accessing the unsplash image library using the API You should regsiter with the website who ll give you a key similar to the one below which you can use to access search for images This example grabs pictures of cats we get the first one and add it to the page output const apiUrl https api unsplash com search photos per_page 24 query const apikey Client ID 1ff567feea79565eafd82a37c3e34e5dacdbb411a117a9bec0bc20ffbd1a8612 fetch apiUrl people headers Authorization apikey then resp return resp json then data console log total data total console log results length data results length console log data results 0 data results 0 urls let img document createElement img img src data results 0 urls regular img style width 90 document body appendChild img console log ready imageSrc result urls regular width result width height result height title result description Untitled name result user name document body style height 400pt const apiUrl https api unsplash com search photos per_page 24 query const apikey Client ID 1ff567feea79565eafd82a37c3e34e5dacdbb411a117a9bec0bc20ffbd1a8612 fetch apiUrl wallpaper headers Authorization apikey then resp return resp json then data console log total data total console log results length data results length for let i 0 i data results length i let img document createElement img img src data results i urls regular img style width 20 document body appendChild img document body style height 900pt console log ready
then data console log total data total console log results length data results length console log data results 0 data results 0 urls let img document createElement img img src data results 0 urls regular img style width 90 document body appendChild img console log ready imageSrc result urls regular width result width height result height title result description Untitled name result user name document body style height 400pt const apiUrl https api unsplash com search photos per_page 24 query const apikey Client ID 1ff567feea79565eafd82a37c3e34e5dacdbb411a117a9bec0bc20ffbd1a8612 fetch apiUrl wallpaper headers Authorization apikey then resp return resp json then data console log total data total console log results length data results length for let i 0 i data results length i let img document createElement img img src data results i urls regular img style width 20 document body appendChild img document body style height 900pt console log ready