Open cncolder opened 2 years ago
const axios = require('axios');
const url = 'https://dog.ceo/api/breeds/image/random.jpg';
axios.get(url, { responseType: 'blob' })
.then((response) => {
if (response.status === 200) {
const blob = response.data;
const image = document.createElement('img');
image.src = URL.createObjectURL(blob);
document.body.appendChild(image);
} else {
console.log('Error getting image.');
}
})
.catch((error) => {
console.log(error);
});
Hope, I answered your question
Currently, all endpoints responds a json. Is there a way to get the image directly?
e.g. https://dog.ceo/api/breeds/image/random.jpg
So that we can embed in markdown: