File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
packages/thirdweb/src/wallets/in-app/core/actions Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Propagate 401 errors when connecting in-app wallet
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export async function getUserStatus({
1717 authToken : string ;
1818 client : ThirdwebClient ;
1919 ecosystem ?: Ecosystem ;
20- } ) : Promise < UserStatus | undefined > {
20+ } ) : Promise < UserStatus > {
2121 const clientFetch = getClientFetch ( client , ecosystem ) ;
2222 const response = await clientFetch (
2323 `${ getThirdwebBaseUrl ( "inAppWallet" ) } /api/2024-05-05/accounts` ,
@@ -32,12 +32,10 @@ export async function getUserStatus({
3232 ) ;
3333
3434 if ( ! response . ok ) {
35- if ( response . status === 401 ) {
36- // 401 response indicates there is no user logged in, so we return undefined
37- return undefined ;
38- }
39- const result = await response . json ( ) ;
40- throw new Error ( `Failed to get user status: ${ result . message } ` ) ;
35+ const result = await response . text ( ) . catch ( ( ) => {
36+ return "Unknown error" ;
37+ } ) ;
38+ throw new Error ( `Failed to get user info: ${ result } ` ) ;
4139 }
4240
4341 return ( await response . json ( ) ) as UserStatus ;
You can’t perform that action at this time.
0 commit comments