I am trying to use the Unsplash API to generate images using a user's input. So far I've been able to retrieve images when query= is hardcoded but I want the results to vary based on what the user types and submits into the query. Below I've hardcoded "dog" as the query input.
Here is my code so far:
var client_id = "fcbcd3e60e7f6615d0e5c64ab8e830d9695c4c30a74586e8d234f9835923ad75";
$("#fieldsubmit").click(function(){
query = $("#query").val();
})
$.getJSON('https://api.unsplash.com/search/photos?page=1&query=dog&client_id=fcbcd3e60e7f6615d0e5c64ab8e830d9695c4c30a74586e8d234f9835923ad75', function(data) {
console.log(data);
var imageList = data.results;
$.each(imageList, function(i, val) {
var image = val;
var imageURL = val.urls.regular;
var imageWidth = val.width;
console.log(imageURL);
$('.grid').append('<div class="image"><img src="'+ imageURL +'"</div>')
});
});