File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,12 @@ export function handleUnsuccessfulApiResponse<T extends SocketSdkOperations>(
1515 result : SocketSdkErrorType < T > ,
1616 spinner : Spinner
1717) {
18- const resultError =
19- 'error' in result && result . error && typeof result . error === 'object'
20- ? result . error
21- : { }
18+ // SocketSdkErrorType['error'] is not typed.
19+ const resultErrorMessage = ( < { error ?: Error } > result ) . error ?. message
2220 const message =
23- 'message' in resultError && typeof resultError . message === 'string'
24- ? resultError . message
21+ typeof resultErrorMessage === 'string'
22+ ? resultErrorMessage
2523 : 'No error message returned'
26-
2724 if ( result . status === 401 || result . status === 403 ) {
2825 spinner . stop ( )
2926 throw new AuthError ( message )
@@ -51,17 +48,17 @@ export async function handleApiCall<T>(
5148
5249export async function handleAPIError ( code : number ) {
5350 if ( code === 400 ) {
54- return ` One of the options passed might be incorrect.`
51+ return ' One of the options passed might be incorrect.'
5552 } else if ( code === 403 ) {
56- return ` You might be trying to access an organization that is not linked to the API key you are logged in with.`
53+ return ' You might be trying to access an organization that is not linked to the API key you are logged in with.'
5754 }
5855}
5956
6057export async function queryAPI ( path : string , apiKey : string ) {
6158 return await fetch ( `${ API_V0_URL } /${ path } ` , {
6259 method : 'GET' ,
6360 headers : {
64- Authorization : ' Basic ' + btoa ( `${ apiKey } :${ apiKey } ` )
61+ Authorization : ` Basic ${ btoa ( `${ apiKey } :${ apiKey } ` ) } `
6562 }
6663 } )
6764}
You can’t perform that action at this time.
0 commit comments