-
Notifications
You must be signed in to change notification settings - Fork 108
refactor: use openapi-fetch #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, non-blocking question. I think I'll try to introduce some more linting rules for more consistency with i.e. strings and arrow functions later.
src/common/atlas/apiClient.ts
Outdated
private errorMiddleware = (): Middleware => ({ | ||
async onResponse({ response }) { | ||
if (!response.ok) { | ||
throw new ApiClientError(`Error calling Atlas API: ${await response.text()}`, response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we guaranteed the response text? is there a chance this could error as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
src/common/atlas/apiClient.ts
Outdated
if (!response.ok) { | ||
try { | ||
const text = await response.text(); | ||
throw new ApiClientError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does mean that what we'll get is
Error calling Atlas API: Error calling Atlas API:...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like Error calling Atlas API: [400 Bad Request] Invalid json or some other text from backend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think passing the response object is sufficient, we can just omit the response text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? response is a property and does not display error message directly. You prefer to hide error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say so. If we want to include properties of the response inside the message (including in format [${response.status} ${response.statusText}]
) then let's do it inside the ApiClientError
class's super
call to message so it's standardized and enforced. And in that sense avoid anything async.
fixes #33