ReqorMiddleware
ts
type ReqorMiddleware = {
before?: (context: ReqorMiddlewareContext) => void | Partial<Pick<ReqorMiddlewareContext, "url" | "init">> | Promise<void | Partial<Pick<ReqorMiddlewareContext, "url" | "init">>>;
after?: (response: Reqor.Response, context: ReqorMiddlewareContext) => void | Reqor.Response | Promise<void | Reqor.Response>;
onError?: (error: any, context: ReqorMiddlewareContext) => void | any | Promise<void | any>;
};The type for a Global/Instance Middleware in reqor.
Properties
.before?: (context: ReqorMiddlewareContext) => void | Partial<Pick<ReqorMiddlewareContext, "url" | "init">> | Promise<void | Partial<Pick<ReqorMiddlewareContext, "url" | "init">>>
A function that executes BEFORE a get or post function is processed
Before a whole attempt, not every retry Attempt
The before middleware runs before a whole attempt, not every try.
.after?: (response: Reqor.Response, context: ReqorMiddlewareContext) => void | Reqor.Response | Promise<void | Reqor.Response>;
A function that executes AFTER a get or post function's main purpose is processed
After a whole attempt, not every retry Attempt
The after middleware runs after a whole attempt, not every try.
.onError?: (error: any, context: ReqorMiddlewareContext) => void | any | Promise<void | any>;
A function that runs if a error is caught while processing
