neynarxyz / nodejs-sdk

Typescript SDK for Neynar APIs
https://neynar.com
MIT License
50 stars 10 forks source link

feat: add `fetchCastsForUser` method #155

Closed eurbs closed 1 month ago

eurbs commented 1 month ago

Included Changes

Test Plan

Tested by writing a and running a script

(async () => {
    console.log('Trying out client.fetchCastsForUser');
    try {
        const res = await client.fetchCastsForUser(3, {});

        // Stringify and log the response
        console.log('Got your response: ')
        console.log(JSON.stringify(res));

        // Also works fine with optional params
        const res2 = await client.fetchCastsForUser(
            3,
            {
                limit: 2,
                cursor: 'eyJ0aW1lc3RhbXAiOiIyMDI0LTA4LTIwIDE5OjQyOjU3LjAwMDAwMDAifQ%3D%3D',
                includeReplies: false,
            }
        );
        console.log('Got your second response: ')
        console.log(JSON.stringify(res));
        console.log('Num results: ', res2.casts.length);
      } catch (error) {
        // isApiErrorResponse can be used to check for Neynar API errors
        if (NeynarV2APIClient.isApiErrorResponse(error)) {
          console.log("API Error", (error as any).response.data);
        } else {
          console.log("Generic Error", error);
        }
      }
    console.log('gn');
})();