Как правильно сравнить статус с Unauthorized (401)? async function authFetch(url,…
- User
Как правильно сравнить статус с Unauthorized (401)? async function authFetch(url, options = {}) { const hashedPassword = await hashPassword(adminPassword); const headers = { ...options.headers, 'Authorization': 'Basic ' + hashedPassword }; const response = fetch(url, { ...options, headers }); if (response.status === Unauthorized) { // Если получили 401, сбрасываем пароль и показываем окно авторизации sessionStorage.removeItem('adminPassword'); adminPassword = ''; showAuthModal = true; } return response; }
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.