Skip to content

Commit

Permalink
hw10
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwiseturtle committed Aug 3, 2023
1 parent ad6384b commit 36cf887
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/js/cat-api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import axios from 'axios';

const BASE_URL = 'https://api.thecatapi.com/v1';
const API_KEY =
'live_NqCT8Nwkxuj6edZ1OwQGKuojQMkYLWj7L4oQ3fZLryh0xj2BQo0SHp9dUXgOOBta';
const API_KEY = 'live_NqCT8Nwkxuj6edZ1OwQGKuojQMkYLWj7L4oQ3fZLryh0xj2BQo0SHp9dUXgOOBta';

export function fetchBreeds(URL) {
return axios.get(URL).then(result => {
Expand All @@ -11,6 +10,7 @@ export function fetchBreeds(URL) {
}

export function fetchCatByBreed(breedId) {
console.log(breedId);
return axios
.get(`${BASE_URL}/images/search?api_key=${API_KEY}&breed_ids=${breedId}`)
.then(result => {
Expand Down
30 changes: 20 additions & 10 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ function renderData(dataCat) {

loaderItem.hidden = true;
selectBreed.hidden = false;
sectionLoad.hidden = true;

new SlimSelect({
select: '#selectBreed'
});

sectionLoad.hidden = true;

new SlimSelect({
select: '#selectBreed',
});
}

function errorfetchData() {
loaderItem.hidden = true;
// errorItem.hidden = false;
}

//слідкуємо за тим, яку породу користувач вибрав
Expand All @@ -48,12 +46,24 @@ function showInfoBreed(e) {
}

function showCat(infoCat) {
console.log(infoCat);
divInfoCat.innerHTML = '';
const markup = createMarkupCatShow(infoCat);
console.log(markup);
divInfoCat.innerHTML = markup;
console.log(divInfoCat);
}

Notiflix.Notify.init({
width: '480px',
position: 'left-top',
distance: '90px',
opacity: 1,
fontSize: '20px',
clickToClose: true,
timeout: 1000,
// ...
});

function errorGetInfoCat(error) {
// Notiflix.Notify.warning(error);
console.log('x');
Notiflix.Notify.failure('Немає інформації по цьому котику!');
}

0 comments on commit 36cf887

Please sign in to comment.