Показать сообщение отдельно
  #3 (permalink)  
Старый 12.03.2024, 11:07
Аватар для Alexandroppolus
Профессор
Отправить личное сообщение для Alexandroppolus Посмотреть профиль Найти все сообщения от Alexandroppolus
 
Регистрация: 25.10.2016
Сообщений: 1,005

ты опять забыл return

function getGoodsList(step = 0) {
  return fetch(`http://localhost:3000/api/products`)
    .then(res => {
      if (res.status === 404) {
        throw new Error ('404');
      }
      if (res.status === 500) {
        if (step < 2) {
          return getGoodsList(++step);
        }
        else {
          throw new Error ('500');
        }
      }
      return res.json();
    });
}
Ответить с цитированием