nuxt-custom-fetch 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -50,7 +50,7 @@ onRequest?: ({ request, options }: {
50
50
  request: FetchRequest
51
51
  options: FetchOptions
52
52
  response: FetchResponse<any>
53
- }) => FetchResponse<ResponseType>
53
+ }) => Promise<void> | void
54
54
  onResponseError?: ({
55
55
  request,
56
56
  response,
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "nuxt-http-fetch",
3
3
  "configKey": "httpFetch",
4
- "version": "1.0.2"
4
+ "version": "1.0.3"
5
5
  }
@@ -21,9 +21,8 @@ export const ajax = (url, key, config, options) => {
21
21
  });
22
22
  },
23
23
  onResponse(ctx) {
24
- const resp1 = interceptors.onResponse && interceptors.onResponse(ctx);
25
- const resp2 = onResponse && onResponse({ ...ctx, response: resp1 || ctx.response });
26
- return resp2 || resp1 || ctx.response;
24
+ interceptors.onResponse && interceptors.onResponse(ctx);
25
+ onResponse && onResponse(ctx);
27
26
  },
28
27
  onResponseError(ctx) {
29
28
  [interceptors.onResponseError, onResponseError].map((fn) => fn && fn(ctx));
@@ -63,8 +62,7 @@ export class HTTP {
63
62
  },
64
63
  onRequestError: config.onRequestError || function() {
65
64
  },
66
- onResponse: config.onResponse || function({ response }) {
67
- return response;
65
+ onResponse: config.onResponse || function() {
68
66
  },
69
67
  onResponseError: config.onResponseError || function() {
70
68
  }
@@ -1,11 +1,4 @@
1
1
  import type { FetchRequest, FetchOptions, FetchError, FetchResponse } from 'ofetch';
2
- interface ResponseMap {
3
- blob: Blob;
4
- text: string;
5
- arrayBuffer: ArrayBuffer;
6
- stream: ReadableStream<Uint8Array>;
7
- }
8
- declare type ResponseType = keyof ResponseMap | 'json';
9
2
  export interface OnRequestType {
10
3
  request: FetchRequest;
11
4
  options: FetchOptions;
@@ -32,13 +25,13 @@ export type HTTPConfig = {
32
25
  offline?: () => void;
33
26
  onRequest?: ({ request, options }: OnRequestType) => void;
34
27
  onRequestError?: ({ request, options, error }: OnRequestErrorType) => void;
35
- onResponse?: ({ request, response, options }: OnResponseType) => FetchResponse<ResponseType>;
28
+ onResponse?: ({ request, response, options }: OnResponseType) => Promise<void> | void;
36
29
  onResponseError?: ({ request, response, options }: OnResponseErrorType) => void;
37
30
  };
38
31
  export interface Interceptors {
39
32
  onRequest?: ({ request, options }: OnRequestType) => void;
40
33
  onRequestError?: ({ request, options, error }: OnRequestErrorType) => void;
41
- onResponse?: ({ request, response, options }: OnResponseType) => FetchResponse<ResponseType>;
34
+ onResponse?: ({ request, response, options }: OnResponseType) => Promise<void> | void;
42
35
  onResponseError?: ({ request, response, options }: OnResponseErrorType) => void;
43
36
  }
44
37
  export type AjaxConfig = FetchOptions & {
@@ -46,4 +39,3 @@ export type AjaxConfig = FetchOptions & {
46
39
  offline?: () => void;
47
40
  interceptors: Interceptors;
48
41
  };
49
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-custom-fetch",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {