Skip to content
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

added backslashes at the end of each route in api.ts #2581

Closed
wants to merge 6 commits into from

Conversation

Marmik2003
Copy link
Contributor

fixes #2580

@Marmik2003 Marmik2003 requested a review from a team May 30, 2022 09:08
@rithviknishad
Copy link
Member

@Marmik2003 deploy preview is failing. merge the latest develop branch.

@Marmik2003 Marmik2003 requested a review from a team as a code owner June 2, 2022 13:41
src/Redux/api.tsx Outdated Show resolved Hide resolved
@Ashesh3
Copy link
Member

Ashesh3 commented Jun 3, 2022

I feel not all endpoints in api.ts need a trailing slash, and adding it in some cases will cause malfunction.

For instance, Updating a Facility fails with this change. This is because of the way fireRequest works.

export const fireRequest = (
...
    if (path.length > 0) {
      request.path += "/" + path.join("/");
    }
...

Adding a trailing slash to updateFacility key in the api.ts would lead to the final URL being:
http://localhost:4000/api/v1/facility//4a3dbe9c-8d1b-4dc1-b939-237d79d96233
(Notice the double slash there).

Which obviously errors out:
image

Some endpoints in api.ts are to be without end slashes for the above reason.

I believe this issue would be resolved better with this PR: #2395
This is because the mentioned PR modifies how fireRequest works and just adds a trailing slash on the fly whenever and only when its necessary.

@Marmik2003 Marmik2003 closed this Jun 3, 2022
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.

Ending Backslashes missing in api paths
3 participants