This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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}`) |