MCPcopy Index your code
hub / github.com/didi/mpx / constructor

Method constructor

packages/fetch/src/xfetch.js:10–31  ·  view source on GitHub ↗
(options, MPX)

Source from the content-addressed store, hash-verified

8
9export default class XFetch {
10 constructor (options, MPX) {
11 this.CancelToken = CancelToken
12 this.cacheRequestData = {}
13 // this.requestAdapter = (config) => requestAdapter(config, MPX)
14 // 当存在 useQueue 配置时,才使用 this.queue 变量
15 if (options && options.useQueue && typeof options.useQueue === 'object') {
16 this.queue = new RequestQueue(extend({
17 adapter: (config) => requestAdapter(config, MPX)
18 }, options.useQueue))
19 } else {
20 this.requestAdapter = (config) => requestAdapter(config, MPX)
21 }
22 if (options && options.proxy) this.setProxy(options.proxy)
23 this.onValidatorError = options?.onValidatorError || (error => {
24 console.error(error)
25 })
26 this.interceptors = {
27 request: new InterceptorManager(),
28 response: new InterceptorManager()
29 }
30 this.useBigInt = (options && options.useBigInt) || false
31 }
32
33 static normalizeConfig (config) {
34 if (!config.url) {

Callers

nothing calls this directly

Calls 2

setProxyMethod · 0.95
errorMethod · 0.45

Tested by

no test coverage detected