export const searchForUserByScreenName = async (client: TwitterOpenApiClient, screenName: string) => {
const user = await client.getUserApi().getUserByScreenName({ screenName })
return user
}
// assume that client has been initiated correctly
// works well
await searchForUserByScreenName(client,'elonmask')
// works well
await searchForUserByScreenName(client,'LeeWendao')
// works bad because `Wendaoleecs` is not a existed user
// and it throw error
await searchForUserByScreenName(client,'Wendoleecs')
Error
Uncaught TypeError: Cannot read properties of undefined (reading 'result')
at UserApiUtils.<anonymous> (D:\Backup\Documents\GitHub\AI-Daily-Inner-Data-Devlop-Platform\node_modules\twitter-openapi-typescript\src\apis\userApi.ts:34:25)
at step (D:\Backup\Documents\GitHub\AI-Daily-Inner-Data-Devlop-Platform\node_modules\twitter-openapi-typescript\dist\src\apis\userApi.js:44:23)
Suggestion
Seems that the code at src/apis/userApi.ts at line 34:
Sample Code
Error
Suggestion
Seems that the code at
src/apis/userApi.ts
at line 34:Should be corrected to:
But I'm not sure.