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({
17
17
authToken : string ;
18
18
client : ThirdwebClient ;
19
19
ecosystem ?: Ecosystem ;
20
- } ) : Promise < UserStatus | undefined > {
20
+ } ) : Promise < UserStatus > {
21
21
const clientFetch = getClientFetch ( client , ecosystem ) ;
22
22
const response = await clientFetch (
23
23
`${ getThirdwebBaseUrl ( "inAppWallet" ) } /api/2024-05-05/accounts` ,
@@ -32,12 +32,10 @@ export async function getUserStatus({
32
32
) ;
33
33
34
34
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 } ` ) ;
41
39
}
42
40
43
41
return ( await response . json ( ) ) as UserStatus ;
You can’t perform that action at this time.
0 commit comments