Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Надо подкачаться #16

Merged
merged 7 commits into from
Jan 14, 2025

Conversation

Daniil888-m
Copy link
Contributor

@Daniil888-m Daniil888-m commented Jan 13, 2025

@keksobot keksobot changed the title Realized taking data from server, catching errors, showing alerts on … Надо подкачаться Jan 13, 2025
keksobot pushed a commit that referenced this pull request Jan 13, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jan 14, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jan 14, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jan 14, 2025
js/api.js Outdated
}).catch(() => {
throw new Error('Ошибка при отправке/получении данных');
});
const getData = () => fetch(`${BASE_URL}${Route.GET_DATA}`).then((response) => response.json());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем вызывать тут fetch если выше объявлена функция load

js/api.js Outdated
});
const getData = () => fetch(`${BASE_URL}${Route.GET_DATA}`).then((response) => response.json());
const sendData = (body) => load(Route.SEND_DATA, Method.POST, body);
let getPictures = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPictures перенести в main, эта функция является более высокоуровневой и не может находиться в модуле api

функции должны быть объявлены через const и их нельзя переопределять

js/api.js Outdated
};
};

getPictures = getPictures();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Крайне спорная конструкция, лучше завести глобальную переменную и присвоить ей результат вызова getData

js/main.js Outdated

document.addEventListener('click', (e) => {
const currentPicture = e.target.closest('.picture');

if (currentPicture) {
e.preventDefault();
openBigPhotoPopup(currentPicture.dataset.photoId);
getPictures().then((photos) => openBigPhotoPopup(photos, currentPicture.dataset.photoId), showDataError);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Получать данные с сервера при каждом открытии полноэкранного изображения неприемлемо

@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jan 14, 2025
@keksobot
Copy link
Contributor

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jan 14, 2025
@keksobot keksobot merged commit 3887a03 into htmlacademy-javascript:master Jan 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants