Cat Api Key not working

Hi!
I’m makeing a test project using this great API but just the test one (the one in the postman’s docu) works.
When I change with mine (the one I get from the registration) it gives me back an empty array.
I obtained two keys to be sure, but none works.
I’m using XMLHttpRequest and I repeat, the test one works

function getUserDataWithPromise() {
var xhr = new XMLHttpRequest();
return new Promise(function (resolve, reject) {
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 300) {
reject("Error, status code = " + xhr.status);
} else {
resolve(xhr.responseText);
}
}
};
xhr.open(
“GET”,
https://api.thecatapi.com/v1/images/?limit=10&page=0&order=DESC”,
true
);
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.setRequestHeader(“x-api-key”, “MY KEY”);
xhr.send();
});
}

I tried to put it into the query with ?api_key=XXXX but is the same

Any idea?
Thanks

Have you uploaded any images with that key yet? if not then empty array will be correct. A wrong key should give you an error.

Thanks for the reply.
But no. I simply want to get random images.
I misunderstood something then…

What I’m supposed to do get simply get random images?

So /images/ will return ALL your images uploaded from your API account, if you just want random ones from the site itself then use /images/search also remember default limit is 1 is remember to pass that param if you want more

1 Like

Thanks!
Sorry it was so simple…

Sorry another question…
How can I get random images?
Just creating random numbers in the page paramenter?

yeah pretty much, cant see any other way