Как мне остановить выполнение скрипта на этапе .then при получении?Я хочу, чтобы скрипт прекратил выполнение, если response и response.text не пустые
fetch(url, {
method: 'POST',
body: data,
credentials: 'include',
})
.then(response => response.text())
.then(html => {
if (html && html.length) {
$('#modal-content').html('');
$('#modal-content').append(html);
//STOP here.
}
})
.then(({ status }) => {
if (status === 200) {
document.location.reload(true);
}
})
UPD: я закончил тем, что написал другое условие if для
if (status === 200 && $('#notavailable-modal').length == 0) {
document.location.reload(true);
}