Skip to content

Instantly share code, notes, and snippets.

View dvbeelen's full-sized avatar

Dion van Beelen dvbeelen

View GitHub Profile
@dvbeelen
dvbeelen / unsplashSourceApi.js
Last active April 9, 2019 14:54
How To: Connect to the Unsplash Source API
//With the code below, you can connect to the Unsplash Source API. This API contains a lot of high-end images to use for free.
//I uploaded this here because I couldn't find how to do this anywhere online. Enjoy!
const imageWidth = 200; //Here you set how many pixels wide you want the recieved picture to be
const imageHeight = 200; //Here you set how many high you want the recieved picture to be
const searchTerm = ["house"]; //Here you set the term you want the API to search for.
const image = document.getElementsById("yourImage"); //Here you define which image you want to change.
fetch(`https://source.unsplash.com/${imageWidth}x${imageHeight}/?${searchTerm}`)