We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f95a56 commit d891175Copy full SHA for d891175
src/core/client.ts
@@ -51,7 +51,18 @@ async function post<T>(
51
errors: json.errors || {},
52
};
53
}
54
- return <T>(await response.json()).data;
+ // we still need to check for error as the API can return 200 with errors
55
+ const json = await response.json();
56
+ if (json.errors) {
57
+ throw {
58
+ code: 400,
59
+ statusText: 'Error was returned from the API',
60
+ message: json.errors[0].message,
61
+ errors: json.errors || {},
62
+ };
63
+ }
64
+
65
+ return <T>json.data;
66
} catch (exception) {
67
throw exception;
68
0 commit comments