-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: Create API Layer and custom Hook to use the API #1434
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1434 +/- ##
=========================================
Coverage ? 12.43%
=========================================
Files ? 274
Lines ? 6990
Branches ? 1318
=========================================
Hits ? 869
Misses ? 4955
Partials ? 1166
Continue to review full report at Codecov.
|
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.
Great changes @rodrigolabs, this would be a very good feature once we start to use it. 👍
Why do we have it implemented on Viewer level?
Maybe we could add it as an OHIF/core so we can use in other extensions, packages as well.
Code changes looks good to me, with some minimal questions.
Great job! 🎊
"lodash": "4.17.15", | ||
"lodash.clonedeep": "4.5.0" | ||
"lodash.clonedeep": "4.5.0", | ||
"react-test-renderer": "^16.12.0" |
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 using this package?
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.
Yes, because of @testing-library/react-hooks
. It uses react-test-renderer
but it doesn't come bundled together to allow us to install a specific version of react-test-renderer
.
platform/viewer/src/api/baseUrls.js
Outdated
@@ -0,0 +1,3 @@ | |||
export default { | |||
studies: 'url', |
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.
Any reason to add this data here? Can it be empty?
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 is just an initial file for us to keep in mind that we should centralize API URLs there.
I'll remove the studies
key/value and keep this file empty for future use :)
Thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
Currently, we have API calls on the client sprinkled around, and where/how we make requests is not always obvious.
This PR creates an API Layer to try to reduce data calls and use them in the top-level containers. The goal is to centralize all of our web requests to a single layer.
This new API layer is a generic layer that uses
axios
to manage the calls.Also, a generic custom hook
useApi
was created to consume the new API layer. The intention with the hook is to have a UI handler separated from the API layer itself, where we'll be able to handle each call better, having its status likeisLoading
,isError
and thedata
per call. This hook can be reusable, even extendable.useApi
-- new custom hookBasic example