Interceptors
Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to the rest of your application. Below is an example request interceptor
ts
OpenAPI.interceptors.request.use((request) => {
doSomethingWithRequest(request)
return request // <-- must return request
})
ts
OpenAPI.interceptors.request.eject((request) => {
doSomethingWithRequest(request)
return request // <-- must return request
})
and an example response interceptor
ts
OpenAPI.interceptors.response.use(async (response) => {
await doSomethingWithResponse(response) // async
return response // <-- must return response
})
ts
OpenAPI.interceptors.response.eject(async (response) => {
await doSomethingWithResponse(response) // async
return response // <-- must return response
})
TIP
To eject, you must provide the same function that was passed to use()
.
WARNING
Angular client does not currently support request interceptors.