Cat API Example
Kevin Wilde
Last Update 3 months ago
The Cat API returns random images of cats.
See this example in action:
Demo store password: eacoht
https://apiease-demo.myshopify.com/pages/auth-api
Here is the Cat API endpoint being called:
https://api.thecatapi.com/v1/images/search
JavaScript
xxxxxxxxxx
12
1
function callApi() {
2
const queryParamsCaller = new URLSearchParams({
3
requestId: "72277ed0-db24-11ed-b56c-119d120a4914",
4
});
5
fetch('/apps/apiease/integration/caller/call?' + queryParamsCaller,
6
{headers: {'ngrok-skip-browser-warning': 'any'}}).
7
then(function(response) {return response.json();}).
8
then(function(jsonResponse) {
9
console.log(jsonResponse);
10
document.getElementById("catApiResponseImage").src = jsonResponse.data[0].url;
11
});
12
}
HTML
xxxxxxxxxx
12
1
<div id="demoHtml">
2
<div id="catApiDemo">
3
<div style="display: flex; align-items: center;">
4
<p>The Cat API returns random images of cats.</p>
5
<button onclick="callApi()">Get</button>
6
</div>
7
<div class="response-box">
8
APIEase Response:<br>
9
<img id="catApiResponseImage">
10
</div>
11
</div>
12
</div>
CSS
xxxxxxxxxx
20
1
<style>
2
#demoHtml * {
3
font-family: 'Helvetica Neue', sans-serif;
4
}
5
#demoHtml button {
6
padding: 8px 12px;
7
background-color: #007bff;
8
color: #fff;
9
border: none;
10
border-radius: 4px;
11
cursor: pointer;
12
}
13
.response-box {
14
position: relative;
15
border: 1px solid #ccc;
16
padding: 10px;
17
background-color: #e6ecff;
18
margin-top: 10px;
19
}
20
</style>