Skip to content

fix: add response.ok checks to all frontend fetch calls #27

@gordonmurray

Description

@gordonmurray

All fetch() calls in app.js call response.json() without first checking response.ok. If the backend returns a 4xx or 5xx error, the error JSON is silently parsed as valid data, which can cause confusing behavior in the UI.

Example (current):

const response = await fetch(`/datasets/${name}/rows?...`);
const data = await response.json();
// data might be an error object, but we treat it as row data

Proposed fix: Add a guard before each .json() call:

const response = await fetch(`/datasets/${name}/rows?...`);
if (!response.ok) {
    throw new Error(`API error: ${response.status} ${response.statusText}`);
}
const data = await response.json();

Applies to every fetch() call in app.js.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions