Skip to content

Commit

Permalink
Merge pull request #67 from rolling-scopes-school/js30-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleostro authored Sep 27, 2023
2 parents 0f0ec45 + 2879f36 commit 298ed59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions image-galery/dev/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const searchInp = document.querySelector('.header-search__input');
const searchBtn = document.querySelector('.header-search__btn-search');
const cleanBtn = document.querySelector('.header-search__btn-clean');

let url = `https://api.unsplash.com/photos/random?count=30&client_id=SouHY7Uul-OxoMl3LL3c0NkxUtjIrKwf3tsGk1JaiVo`;
let url = `https://api.unsplash.com/photos/random?count=30&client_id=or0oG32zRnb7HAhV-Fkff1WomO_bb5XQYSqlzNLVMaU`;

async function getData(url) {
const res = await fetch(url)
Expand Down Expand Up @@ -42,7 +42,7 @@ const showData = (data) => {

searchBtn.addEventListener('click', () => {
galeryContainer.innerHTML = '';
url = `https://api.unsplash.com/photos/random?query=${searchInp.value}&count=30&client_id=SouHY7Uul-OxoMl3LL3c0NkxUtjIrKwf3tsGk1JaiVo`;
url = `https://api.unsplash.com/photos/random?query=${searchInp.value}&count=30&client_id=or0oG32zRnb7HAhV-Fkff1WomO_bb5XQYSqlzNLVMaU`;
getData(url);
});

Expand All @@ -52,7 +52,7 @@ cleanBtn.addEventListener('click', () => {

searchInp.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && searchInp.value !== '') {
url = `https://api.unsplash.com/photos/random?query=${searchInp.value}&count=30&client_id=SouHY7Uul-OxoMl3LL3c0NkxUtjIrKwf3tsGk1JaiVo`;
url = `https://api.unsplash.com/photos/random?query=${searchInp.value}&count=30&client_id=or0oG32zRnb7HAhV-Fkff1WomO_bb5XQYSqlzNLVMaU`;
getData(url);
} else if (e.key === 'Escape') searchInp.value = '';
});
Expand Down

0 comments on commit 298ed59

Please sign in to comment.