Skip to content

Commit

Permalink
Include isApiErrorResponse in docs
Browse files Browse the repository at this point in the history
Include isApiErrorResponse in docs
  • Loading branch information
Shreyaschorge authored Nov 17, 2023
2 parents 3a98ff0 + 367febb commit fff0f77
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Add following code in index.ts
```typescript
// index.ts

import { NeynarAPIClient } from "@neynar/nodejs-sdk";
import { NeynarAPIClient, isApiErrorResponse } from "@neynar/nodejs-sdk";
import { AxiosError } from "axios";

// Instantiate the client
Expand All @@ -64,8 +64,13 @@ const client = new NeynarAPIClient("<YOUR_API_KEY_HERE>"); // Replace with your
// Stringify and log the response
console.log(JSON.stringify(user));
} catch (error) {
// Log the error
console.log((error as AxiosError).response?.data);
// isApiErrorResponse can be used to check for Neynar API errors
// handle errors accordingly
if (isApiErrorResponse(error)) {
console.log("API Error", error.response.data);
} else {
console.log("Generic Error", error);
}
}
})();
```
Expand Down

0 comments on commit fff0f77

Please sign in to comment.