-
Notifications
You must be signed in to change notification settings - Fork 1
Надо подкачаться #12
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
Надо подкачаться #12
Conversation
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
js/api.js
Outdated
`${BASE_URL}/${endpoint[0] === '/' ? endpoint.slice(1) : endpoint}`; | ||
|
||
const dataHandler = async (response) => { | ||
if (response.status < 400) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
400 — магическое и должен быть 200
.then((posts) => { | ||
drawMiniatures(posts); | ||
}) | ||
.catch(() => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить ошибку
js/notification.js
Outdated
const successTemplate = document.getElementById('success').content; | ||
|
||
const showMessage = (template, config = {}) => { | ||
const timeout = (config.timeout ?? 5) * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
магические значения
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
|
||
const isSuccess = (response) => { | ||
// Статусы 200..299 считаем успешными (https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status) | ||
if (response.status >= 200 && response.status < 300) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
числа 200 и 300 считаются магическими, надо вынести в константы
|
||
const isError = (response) => { | ||
// 400 и далее - ошибка (всё та же спецификация) | ||
if (response.status >= 400) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
400 магическое
🎓 Надо подкачаться
💥 https://htmlacademy-javascript.github.io/2586431-kekstagram-2/12/