Skip to content

Commit

Permalink
Bugfix/add check for error response data type
Browse files Browse the repository at this point in the history
Bugfix/add check for error response data type
  • Loading branch information
Shreyaschorge authored Jan 12, 2024
2 parents 3b91048 + 76d117a commit bed9b89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/nodejs-sdk",
"version": "1.6.0",
"version": "1.6.1",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
9 changes: 6 additions & 3 deletions src/neynar-api/v1/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export class NeynarV1APIClient {
if (NeynarV1APIClient.isApiErrorResponse(error)) {
const apiErrors = error.response.data;
this.logger.warn(`API errors: ${JSON.stringify(apiErrors)}`);
} else {
this.logger.warn(
`Unexpected error: ${JSON.stringify(error, null, 2)}`
);
}
throw error;
}
Expand Down Expand Up @@ -109,9 +113,8 @@ export class NeynarV1APIClient {
error: any
): error is SetRequired<AxiosError<ErrorRes>, "response"> {
if (!(error instanceof AxiosError)) return false;
return (
error.response?.data !== undefined && "message" in error.response.data
);
const data = error.response?.data;
return typeof data === "object" && data !== null && "message" in data;
}

// ------------ User ------------
Expand Down

0 comments on commit bed9b89

Please sign in to comment.