mirror of
https://github.com/pyscript/pyscript.git
synced 2026-05-15 22:01:01 -04:00
Use response.ok instead of just status 200 (#999)
This commit is contained in:
@@ -8,7 +8,8 @@ import { FetchError, ErrorCode } from "./exceptions";
|
||||
*/
|
||||
export async function robustFetch(url: string, options?: RequestInit): Promise<Response> {
|
||||
const response = await fetch(url, options);
|
||||
if (response.status !== 200) {
|
||||
// Note that response.ok is true for 200-299 responses
|
||||
if (!response.ok) {
|
||||
const errorMsg = `Fetching from URL ${url} failed with error ${response.status} (${response.statusText}).`;
|
||||
switch(response.status) {
|
||||
case 404:
|
||||
|
||||
Reference in New Issue
Block a user