Skip to content

Conversation

@Asraye
Copy link

@Asraye Asraye commented Aug 25, 2025

Previously, the API client would throw a JSON parse error if a response body was empty, this checks for that and handles it without throwing an error – fixes the bug reported on frontend repo here

Please make sure to check the following tasks before opening and submitting a PR

  • I understand and have followed the contribution guide
  • I have tested my changes locally and they are working as intended
    ↑ Unable to test it locally

Copy link
Contributor

@insertish insertish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better solution is to just check:

Comment on lines -208 to +227
const data = await fetchdata[config?.responseType || "json"]();
let data: any;
const text = await fetchdata.text();
if (text) {
switch (config?.responseType || "json") {
case "json":
data = JSON.parse(text);
break;
case "text":
data = text;
break;
case "blob":
data = new Blob([text]);
break;
case "arrayBuffer":
data = new TextEncoder().encode(text).buffer;
break;
}
} else {
data = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the blob/arrayBuffer cases (although not used) are prone to error here.
I'm not sure if it's a good idea to go straight to text..

@insertish
Copy link
Contributor

I guess the patch should also go to https://github.com/insertish/oapi so I will apply the fix using 204 check.

@insertish insertish closed this in 6e2bd5c Aug 29, 2025
@github-project-automation github-project-automation bot moved this from 🆕 Untriaged to Closed in Pull Request Overview Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants