MCPcopy
hub / github.com/ecyrbe/zodios / interceptResponse

Method interceptResponse

src/plugins/zodios-plugins.ts:105–123  ·  view source on GitHub ↗

* 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>
  )

Source from the content-addressed store, hash-verified

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

Callers 2

requestMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected