data
data copied to clipboard
Error if payload===null
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);
}
@Makan-seequent Do you have a PR you would like to contribute? Or anyway I can help?
@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.
Hey, I will start working on this you can assign this to me