Function withAdditionalInterceptors

Instantiates the SDK with additional interceptors.

It doesn't override the existing interceptors, but instead push more to the list. This method should be used in conjunction with the initializer createAdvancedClient.

withAdditionalInterceptors([
{
request: ({ request }) => {
console.log(`Do something with ${JSON.stringify(request)}`)
return request
},
response: ({ response }) => {
console.log(`Do something with ${JSON.stringify(response)}`)
return response
},
responseError: async ({
request,
error,
}: {
request: Request
error: unknown
}) => {
console.log(
`Do something with ${JSON.stringify(request)} and ${JSON.stringify(
error,
)}`,
)
throw error // or return Promise.resolve(someData)
},
},
])