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

Error if payload===null #7916

Open
Makan-seequent opened this issue Mar 8, 2022 · 3 comments · May be fixed by #8305
Open

Error if payload===null #7916

Makan-seequent opened this issue Mar 8, 2022 · 3 comments · May be fixed by #8305
Assignees
Labels
🏷️ bug This PR primarily fixes a reported issue v4-to-v5 Tickets related to v4 to v5 migration paths

Comments

@Makan-seequent
Copy link

Makan-seequent commented Mar 8, 2022

Sorry not following the issue reporting instruction but this one is a simple error happening here
If the backend response payload=null (I know it shouldn't) and because Javascript consider the "null" as an object it throws error when trying resolve "payload.errors"
Indeed it passes through the guard that I think it's provided to prevent this kind of errors.

    if (this.isSuccess(status, headers, payload)) {
      return payload;
    } else if (this.isInvalid(status, headers, payload)) {
      return new InvalidError(typeof payload === 'object' && 'errors' in payload ? payload.errors : undefined);
    }
@snewcomer
Copy link
Contributor

@Makan-seequent Do you have a PR you would like to contribute? Or anyway I can help?

@Makan-seequent
Copy link
Author

@snewcomer
Not really I don't have PR as I'm not sure where is the right place to consolidate this guard.
But I can imagine something like bellow code which payload && added may works.

return new InvalidError(payload && typeof payload === 'object' && 'errors' in payload ? payload.errors : undefined);

Thank you for taking care of this.

@runspired runspired added the Bug label Aug 12, 2022
@mani-rsg
Copy link

Hey, I will start working on this you can assign this to me

@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
@runspired runspired added the v4-to-v5 Tickets related to v4 to v5 migration paths label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue v4-to-v5 Tickets related to v4 to v5 migration paths
Projects
Status: stalled
Development

Successfully merging a pull request may close this issue.

4 participants