Hi I am working on a project where I need to take the api https://dog.ceo/api. Extract data for Breeds, sub breeds and images and output them to a 3 column CSV file. I have tried hitting the API as a whole and continue to get CORS errors but I am able to freely hit the endpoints which seem to be able to give me sufficient data. I really am not sure how to proceed. This is what I have so far and I feel like im on the right path but also unable to figure out what I need to do next.
fetch('https://dog.ceo/api/breeds/list/all')
.then(res => res.json())
.then(data => handle(data))
.catch(error => console.log('Error'));
function handle(inputData) {
const headers = ['Breed', 'Sub_Breed', 'Image'];
console.log(inputData);
const main = inputData.map(item => {
return item.toString();
});
console.log(main);
}
I am able to console log all of the breeds / sub breeds from inputData but it comes from the object “message:”. I am usually good at figuring things out but I cannot for the life of me figure out what I need to do here. This is a simple web application I built and view in the browser. It is a personal project so I am not necessarily working from any server, just html, CSS, JS files. Any tips or push in the right direction are much appreciated.
I have tried to hit the API as a whole because instructions for that are much clearer, but at the moment I am only able to hit specific endpoints for data. Unsure what I need to do to get this to work the way I need to. the API site is https://dog.ceo/dog-api/