Skip to content

Commit

Permalink
11
Browse files Browse the repository at this point in the history
  • Loading branch information
Elostay committed Sep 28, 2023
1 parent 60e0bce commit 6cef402
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/js/cat-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ axios.defaults.headers.common['x-api-key'] =
const BASE_URL = 'https://api.thecatapi.com/v1/';
const ENDPOINT = 'breeds';

export function fetchBreeds() {
const fetchBreeds = function () {
return fetch(`${BASE_URL}${ENDPOINT}`).then(response => {
if (!response.ok) {
throw new Error(response.statusText);
}
return response.json();
});
}
};

export function fetchCatByBreed(breedId) {
const fetchCatByBreed = function (breedId) {
return axios.get(
`${BASE_URL}images/search?breed_ids=${breedId}&has_breeds=1`
);
}
};

export { fetchBreeds, fetchCatByBreed };
2 changes: 0 additions & 2 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { fetchBreeds, fetchCatByBreed } from './cat-api.js';
import Notiflix from 'notiflix';
import axios from 'axios';
const axios = require('axios');

const select = document.querySelector('.breed-select');

Expand Down

0 comments on commit 6cef402

Please sign in to comment.