unsplash api javascript example 1

unsplash api javascript example

// set image source to a random image
img.src = "https://source.unsplash.com/random";

// get a random image with the size 800x600
img.src = "https://source.unsplash.com/random/800x600"

// Apply search terms
img.src = "https://source.unsplash.com/1600x900/?nature,water"

// More info: https://source.unsplash.com

Here is what the above code is Doing:
1. Create a new image element
2. Set the image source to a random image
3. Set the image source to a random image with the size 800×600
4. Set the image source to a random image with the size 1600×900 and search terms “nature” and “water”

Similar Posts