Conversation
added 30 commits
February 24, 2020 20:51
…nd method stubs; add empty test file
…to feature/centralize_api_logic # Conflicts: # src/services/api/httpRequest.ts # src/services/api/index.ts
cafca
approved these changes
Jul 29, 2020
cafca
reviewed
Jul 30, 2020
Collaborator
|
@s-pic I have made a number of changes in this PR. I will list only the major changes here:
I have made a comment above about the |
Collaborator
Author
|
Thanks for your remarks, I will get back to it asap. |
s-pic
commented
Jul 30, 2020
Collaborator
Author
s-pic
left a comment
There was a problem hiding this comment.
- flatten the syntax of the options argument to
requestby includingkyOptionsin the main options parameter. I know you mentioned that you think there are good reasons for doing this so maybe we should talk about it. I think the more concise syntax is worth any future namespace clashes if that was your concern, but maybe there's something else I'm not seeing.
Jup, my concern was to to mix up our config props with those for ky.
I see your point and I can live with the change 😃.
I have made a comment above about the
NetworkErrorclass, which I don't like as it is now. We should find a way to fix it.
I will take another shot at it.
cafca
reviewed
Aug 4, 2020
s-pic
commented
Aug 4, 2020
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
change summary
Prepares to solve #https://github.com/FixMyBerlin/fixmy.platform/issues/271 → This just adds the api module to do http requests against our backend and makes it subject to further review. We can than gradually replace de-duped code in pages/Map/apiservice.js, pages/User/apiservice.js and pages/Reports/apiservice.js
motivation and context
We finally want to solve https://github.com/FixMyBerlin/fixmy.platform/issues/57 → Once we have a central api client and a central place to throw api-related errors, we can work on the error handling in the view layer.
updates to dependencies and project setup
kywithky-universal in unit tests so that required browser APIs get polyfilled using node-fetch39fa7eblastOptions()dotenvduring jest setupHow Has This Been Tested?
Run
npm run testto run new unit tests.Aspects marked for discussion
Errors classes:
token handling
This has been implemented using a
beforeRequesthook offered bykyapiServiceknows about our store, a dependency injection would be the cleaner pattern, but then we would need either multiple instances of the apiService or a Singleton. I considered the dependency to me fine since we will propably share the service between different apps.What are the proposed next steps?
Iteratively integrate this, this should be another issue.
Here already some ideas what should happen:
tokenfrom component stateChecklist: