@hapaul/api 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2652,6 +2652,7 @@ interface Middleware<C> {
|
|
|
2652
2652
|
onResponse?: (config: RequestConfig<any, any, C>, response: Response) => Response | Promise<Response>;
|
|
2653
2653
|
onError?: (config: RequestLooseConfig<C>, response: Response, error: {
|
|
2654
2654
|
status: number;
|
|
2655
|
+
code: string;
|
|
2655
2656
|
message: string;
|
|
2656
2657
|
}) => void;
|
|
2657
2658
|
}
|
package/dist/index.js
CHANGED
|
@@ -75,9 +75,12 @@ var Client = class {
|
|
|
75
75
|
response
|
|
76
76
|
};
|
|
77
77
|
if (!isOk) {
|
|
78
|
+
let code = "";
|
|
78
79
|
let message = response.statusText;
|
|
80
|
+
if (typeof error === "object" && "code" in error) code = error.code;
|
|
79
81
|
if (typeof error === "object" && "message" in error) message = error.message;
|
|
80
82
|
for (const middleware of this.middlewares) middleware.onError?.(requestConfig, response, {
|
|
83
|
+
code,
|
|
81
84
|
status,
|
|
82
85
|
message
|
|
83
86
|
});
|