@kevisual/query 0.0.21 → 0.0.22

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.
@@ -197,7 +197,7 @@ declare class Query {
197
197
  * @param fn 处理函数
198
198
  */
199
199
  after(fn: DataOpts['afterResponse']): void;
200
- fetchText(url: string, options?: RequestInit): Promise<Result<any>>;
200
+ fetchText(urlOrOptions?: string | QueryOpts$1, options?: QueryOpts$1): Promise<Result<any>>;
201
201
  }
202
202
 
203
203
  declare class BaseQuery<T extends Query = Query, R extends {
@@ -454,13 +454,20 @@ class Query {
454
454
  after(fn) {
455
455
  this.afterResponse = fn;
456
456
  }
457
- async fetchText(url, options) {
458
- const res = await fetch(url, {
457
+ async fetchText(urlOrOptions, options) {
458
+ let _options = { ...options };
459
+ if (typeof urlOrOptions === 'string' && !_options.url) {
460
+ _options.url = urlOrOptions;
461
+ }
462
+ if (typeof urlOrOptions === 'object') {
463
+ _options = { ...urlOrOptions, ..._options };
464
+ }
465
+ const res = await adapter({
459
466
  method: 'GET',
460
- ...options,
467
+ ..._options,
461
468
  headers: {
462
469
  ...this.headers,
463
- ...(options?.headers || {}),
470
+ ...(_options?.headers || {}),
464
471
  },
465
472
  });
466
473
  if (!res.ok) {
package/dist/query.d.ts CHANGED
@@ -204,7 +204,7 @@ declare class Query {
204
204
  * @param fn 处理函数
205
205
  */
206
206
  after(fn: DataOpts['afterResponse']): void;
207
- fetchText(url: string, options?: RequestInit): Promise<Result<any>>;
207
+ fetchText(urlOrOptions?: string | QueryOpts, options?: QueryOpts): Promise<Result<any>>;
208
208
  }
209
209
 
210
210
  declare class BaseQuery<T extends Query = Query, R extends {
package/dist/query.js CHANGED
@@ -238,13 +238,20 @@ class Query {
238
238
  after(fn) {
239
239
  this.afterResponse = fn;
240
240
  }
241
- async fetchText(url, options) {
242
- const res = await fetch(url, {
241
+ async fetchText(urlOrOptions, options) {
242
+ let _options = { ...options };
243
+ if (typeof urlOrOptions === 'string' && !_options.url) {
244
+ _options.url = urlOrOptions;
245
+ }
246
+ if (typeof urlOrOptions === 'object') {
247
+ _options = { ...urlOrOptions, ..._options };
248
+ }
249
+ const res = await adapter({
243
250
  method: 'GET',
244
- ...options,
251
+ ..._options,
245
252
  headers: {
246
253
  ...this.headers,
247
- ...(options?.headers || {}),
254
+ ...(_options?.headers || {}),
248
255
  },
249
256
  });
250
257
  if (!res.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/query",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",