D
D
Darkness2019-07-20 13:11:27
JavaScript
Darkness, 2019-07-20 13:11:27

Where am I going wrong with the Unsplash API request?

If I do like this:

$.getJSON('https://api.unsplash.com/photos/random?client_id={my key}, function(data){
        console.log(data);
    });


It returns a random image, but the documentation has info that you can choose from the collection, but no matter how I write the request, it comes out 404, namely "the last point was not found".

Example:
$.getJSON('https://api.unsplash.com/photos/random/collections/327760?client_id={my key}, function(data){
        console.log(data); // 404 
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Darkness, 2019-07-20
@AntonBrock

Here is what the correct request looks like.

$.getJSON('https://api.unsplash.com/photos/random?collections=228275&orientation=landscape&count=1&client_id={my key}, function(data){
        console.log(data);
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question