* Intercept the response from server by applying all plugins * @param api - endpoint descriptions * @param config - request config * @param response - response from the server * @returns the modified response
(
api: ZodiosEndpointDefinitions,
config: ReadonlyDeep<AnyZodiosRequestOptions>,
response: Promise<AxiosResponse>
)
| 103 | * @returns the modified response |
| 104 | */ |
| 105 | async interceptResponse( |
| 106 | api: ZodiosEndpointDefinitions, |
| 107 | config: ReadonlyDeep<AnyZodiosRequestOptions>, |
| 108 | response: Promise<AxiosResponse> |
| 109 | ) { |
| 110 | let pluginResponse = response; |
| 111 | for (let index = this.plugins.length - 1; index >= 0; index--) { |
| 112 | const plugin = this.plugins[index]; |
| 113 | if (plugin) { |
| 114 | pluginResponse = pluginResponse.then( |
| 115 | plugin?.response |
| 116 | ? (res) => plugin.response!(api, config, res) |
| 117 | : undefined, |
| 118 | plugin?.error ? (err) => plugin.error!(api, config, err) : undefined |
| 119 | ); |
| 120 | } |
| 121 | } |
| 122 | return pluginResponse; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Get the number of plugins registered |
no outgoing calls
no test coverage detected