{"_id":"umi-request","_rev":"73-56edac4eb72bb992836e2a37005ebcd1","name":"umi-request","dist-tags":{"latest":"1.4.0","beta":"1.0.2-beta.1","beta-refactor":"1.3.4-beta.0"},"versions":{"1.0.0-beta.1":{"name":"umi-request","version":"1.0.0-beta.1","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublish":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"lint-staged"},"author":{"name":"puwei","email":"clock157@163.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.65.1","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"1b6c83e3e6bc1cde1c6b529aa9a5c7342a4b557f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.0-beta.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-PPcav+T2yz3+4zXdxATIs7GDCpJjwmhpbHEYrOl6d01jFIFDY5NCWMmZcfYdvxJ4GlJg0u1HB0pp+JmLPdB9Qg==","shasum":"52995f98735c8726dd7bd0f3e67e25472dfe4e39","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.0-beta.1.tgz","fileCount":5,"unpackedSize":21015,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCmBVCRA9TVsSAnZWagAAFsUP/Re5TwV4C530j7mJoDhH\naqZvk9KfN63eOxh/6RJD+cvjFX6Zh1GtfnJ+eqSwyauP+dNUWTq+FCquwdxt\nI4B4BqEEefWbEpE6vFjGCdZVcBGrA+0A9BigOVcjwLuQBFeuvldjnDcs/wjQ\n95A8EpGnv2gA3cl3PwEfJp8Uop7Map3shDWYHc/e08FMjutX1kEnTLB88fSF\nVPg80E4gNqp+Eeiz9RxU35fsD1o8iceLCkiM2DFhHvGExI6mx+U+RlUKoEiT\npwdSOl701rdUxS4UkfVD/jeIeVVxiyww4P9IN0q/Up6hHwcUoczTs4Hyx0KZ\nVFyIeu55fsHgpMUGB1Vd5mEFvWaswV2lK6ekOL/FikTGc0rveGyG790+E0/M\nZbok4uN1NqdRd7FfxvdVuqVAyNsAUJBcdJV5PV75EhTKKN9WWU2e6QFHbVer\nkCTApnWyM6z2ZGiqFc1I2D5Z1aUKkJ2f1cKSlmW7ZD12fdDLQlmsv6P3Q6BB\nJejggoYLRoVY+RGMkQjqZZozFI1pzTI7Nm7X3M+sDtXJaZed0O7YVhbHrKuH\nYPzV9/idD5qBLtT2C9zWbsaMcrhKg+vsOF9B+pKx9WgT1iFfm+Gy1JlcrB+x\nsyRi5IjBb/DlwJNigQfkkJ6mEzIFHMjIb1Fac77RsJ23vMxfNKdRob6Vn0ki\ncksD\r\n=cEbA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHjwD4R+fQ94Jzr7Q/dApKP6clc/jTkUo+ankj8ACLxgIgEogyDGQUuLLL2fFCRQgguBV2y8YZhjAzkjWHHZC2CGQ="}]},"maintainers":[{"name":"clock157","email":"clock157@163.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.0-beta.1_1544183892707_0.3161340756520279"},"_hasShrinkwrap":false},"1.0.0":{"name":"umi-request","version":"1.0.0","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublish":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.65.1","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"57b773b3cd85f80461746db7742b550a4785074b","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-7JyoVBN2a7FjCUo28/tCPnYn5K99hIvCgT/9iV6EvbeuD73vaH8X3Nc3EHyUhza4RZNgy63lkj/aSWy04pSJUg==","shasum":"20a190aff75eadf9daa5d570f3f69a5cceabbac0","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.0.tgz","fileCount":5,"unpackedSize":20811,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcDg/LCRA9TVsSAnZWagAAgXwP+gLZ7pPfoHHlmn6vuw+F\nHdAFZBM33jU/YimxfJyK4Kjm5r9NGWIfik90WuIrPfWEbeXm7JIlGn36hNQK\nC/6LFv7+Vfe7e8NqohLacqn1kD1/yjKKQLaeY70BL7fgmaHiCdrJBise31F9\nMAhw9EMRYI8E6DoL1D/8jMJM8CPiVK7ZmZBSM+gwlSH11F/N2NQd4Ri798Pk\nYxPr+hmOWkvn14sJ3/y4qHsQLf8CCkwvlKY/rB2aBvNCVnJ9mAxgBergO6Ol\nzzh59114i8Dw20j4BtZLaeO9F0MgQNIU8kXlTYD1Gko6G2j+ApXhFhsGw4k9\nmTTv4JOp5WQJ4a6qnRYlmzbopZ4pY+qigqJGlI04IzyOAgicBmLFoQfRwKzd\nD3SOpyd0QzeQMdMNLEX6tII1LvliUHYttfpkpHwm2eb5EJ8DvXp4+HMATDUl\ngvlpvXBS6cXB0N3i/RUiMZebrP2eYTBMC17x08kxf4xAB8/PQxmS7UbLm3Dh\nkJ97dVRqKSagkCNJmI3wxf0FII+4lkWxGS1qDF1ou7rKq8XZ35RDAEZ9l7Z5\nm6KNdczsPlTZNxT3VRmJpgs2eqSRWghuLr3bAV81kBaAtwNAuWLpaC1Rh7qa\nltT3rHu9K2sc2eo6hpO+X6e3Oa1gsOk3H8FUMTcRWxhtaFuoiAIMBbYJeOtD\nipTf\r\n=NHKD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDRZHlYb3Vy6spA/Dw9mVhenekkxYHDIm9/HpKHiPiIdQIgD/S22+IySo1E19QYq/ILez0ePTACey69Zm59xbooPK4="}]},"maintainers":[{"name":"clock157","email":"clock157@163.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.0_1544425418075_0.14827530385805354"},"_hasShrinkwrap":false},"1.0.1-beta.1":{"name":"umi-request","version":"1.0.1-beta.1","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.68.0","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-terser":"^3.0.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"readme":"## umi-request\n网络请求库，基于 fetch 封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.\n\n--------------------\n\n## 支持的功能\n- url 参数自动序列化\n- post 数据提交方式简化\n- response 返回处理简化\n- api 超时支持\n- api 请求缓存支持\n- 支持处理 gbk\n- 类 axios 的 request 和 response 拦截器(interceptors)支持\n- 统一的错误处理方式\n\n## TODO 欢迎pr\n- [ ] rpc支持\n- [x] 测试用例覆盖85%+\n- [x] 写文档\n- [x] CI集成\n- [x] 发布配置\n- [x] typescript\n\n## 安装\n`npm install umi-request --save`\n\n## request options 参数\n| 参数 | 说明 | 类型 | 可选值 | 默认值 |\n| --- | --- | --- | --- | --- |\n| method | 请求方式 | string | get , post , put ... | get |\n| params | url请求参数 | object | -- | -- |\n| charset | 字符集 | string | utf8 , gbk | utf8 |\n| requestType | post请求时数据类型 | string | json , form | json |\n| data | 提交的数据 | any | -- | -- |\n| responseType | 如何解析返回的数据 | string | json , text , blob , formData ... | json , text |\n| getResponse | 是否获取源response, 返回结果将包裹一层 | boolean | -- | fasle |\n| timeout | 超时时长, 默认毫秒, 写操作慎用  | number | -- | -- |\n| useCache | 是否使用缓存 | boolean | -- | false |\n| ttl | 缓存时长, 0 为不过期 | number | -- | 60000 |\n| prefix | 前缀, 一般用于覆盖统一设置的prefix | string | -- | -- |\n| suffix | 后缀, 比如某些场景 api 需要统一加 .json  | string | -- | -- |\n| errorHandler | 异常处理, 或者覆盖统一的异常处理 | function(error) | -- |\n| headers | fetch 原有参数 | object | -- | {} | \n\nfetch原其他参数有效, 详见[fetch文档](https://github.github.io/fetch/)\n\n## extend options 初始化默认参数, 支持以上所有\n| 参数 | 说明 | 类型 | 默认值 |\n| --- | --- | --- | --- |\n| maxCache | 最大缓存数 | number | 不限 |\n| prefix | 默认url前缀 | string | -- |\n| errorHandler | 默认异常处理 | function(error) | -- |\n| headers | 默认headers | object | {} |\n| params | 默认带上的query参数 | object | {} |\n| ... |\n\n\n## 使用\n```javascript\n// request 是默认实例可直接使用, extend为可配置方法, 传入一系列默认参数, 返回一个新的request实例, 用法与request一致.\nimport request, { extend } from 'umi-request';\n\nconst extendedRequest = extend({\n  maxCache: 10, // 最大缓存个数, 超出后会自动清掉按时间最开始的一个.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // 集中处理错误\n  },\n  headers: {\n    some: 'header'  // 统一的headers\n  },\n  params: {\n    hello: 'world'   // 每个请求都要带上的query参数\n  }\n});\nextendedRequest('/some/api');\n\n// 支持语法糖 如: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// 请求一个api, 没有method参数默认为get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url参数序列化\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post 数据提交简化\n// 当data为object时, 默认requestType: 'json'可不写, header会自动带上 application/json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header会自动带上 application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', 如何处理返回的数据, 默认情况下 text 和 json 都不用加. 如blob 或 formData 之类需要加\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// 提交其他数据, 如文本, 上传文件等, requestType不填, 手动添加对应header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// 默认返回的就是数据体, 如果需要源response来扩展, 可用getResponse参数. 返回结果会多套一层\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// 超时 单位毫秒, 但是超时后客户端虽然返回超时, 但api请求不会断开, 写操作慎用.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// 使用缓存, 只有get时有效. 单位毫秒, 不加ttl默认60s, ttl=0不过期. cache key为url+params组合\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// 当服务端返回的是gbk时可用这个参数, 避免得到乱码\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request拦截器, 改变url 或 options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response拦截器, 处理response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n```\n\n## 错误处理\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * 这里介绍四种处理方式\n */\n/**\n * 1. 统一处理\n * 常用于错误码较规范的项目中, 集中处理错误.\n */\n\nconst codeMap = {\n  '021': '发生错误啦',\n  '022': '发生大大大大错误啦',\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error;   // 如果throw. 错误将继续抛出. \n  // return {some: 'data'}; 如果return, 将值作为返回. 不写则相当于return undefined, 在处理结果时判断response是否有值即可.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // 将自动处理错误, 不用catch. 如果throw了需要catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. 单独特殊处理\n* 如果配置了统一处理, 但某个api需要特殊处理. 则在请求时, 将errorHandler作为参数传入.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n *3. 不配置 errorHandler, 将reponse直接当promise处理, 自己catch.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n*4. 基于response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n```\n\n## 开发和调试\n- npm install\n- npm run dev\n- npm link\n- 然后到你测试的项目中执行 npm link umi-request\n- 引入并使用\n\n## 代码贡献者\n- @clock157\n- @yesmeck\n","readmeFilename":"README.md","gitHead":"33fc339d7d8c06f1e734486d5030f3391136e846","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.1-beta.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-eySroYa54jl7orXoJIHYJL/v2MiBF08g8Eq8gOnxLPXviMl6eYMMZRyNR//Fuwb4KsxJChtjBj3dadxbFvlNeA==","shasum":"0d6158b115137eb58bc772358cf2b08c20457f07","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.1-beta.1.tgz","fileCount":6,"unpackedSize":31585,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcGb9RCRA9TVsSAnZWagAAOc0QAJfOiLxcn+6aruY2T6E+\nzCYV69wnV5TTFRQsWwbo2MCL6/zm1yhvTds2saHhsc0Rye4OZngbk3Wu7PPf\n0NToJOeRZT5AugwwH9jN0g7O+Ods74FYPw27pV83hoBcZLtnpG2blcr0kycK\nmL3PBQq0Cr2qNkXzwTVtnJdBg8sJZKfvCdRkSB4EMbfanwbT/UeEdFXmHYSX\n7s888RWbWSXgw9PksrqqI4b2opUlkyET83S2CgLyJHtkFmnHqocZ2gbZ3lRB\ngBjKf/bcNpToHr7ZmOEGDBKc6WAfzw1kniVDtattnAcMM1omX3oDG4UhZ99v\nu8hFbrHWT9oT4dpWv2G9f6q2qMHFZ7pkZs6Ojmfa9/SByvH822Rr/qkc06+F\nealH3+LTFFaw66Q7iHBDuuBJDwUH2rvBCs9JGa8ZUIc3++tVAufuv3rbg1u4\nWpXInqG4Ckt2YaI5VmWXu4FuSsP+aGC55P4O+pabSLwVENlhhbzlIl8KRJBB\nBGU9HnjEWxx3yAFKpKGbQszlPfuEMASeGjO2HEC7gy88ohZMWzmn4LSSN7z2\nwvVZ8CqA9Ys7R3cVJRATsmxMWiQupJluGDFNSWQqR/B6kVj8tmIIXeN3Trmo\nI2Jl8lkQrExsGfBkxgJEwi1TZBRAYRUtMJwAB9rmFbrIJfcwVm1yisA6Pn7m\nr7az\r\n=zr++\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVeD7HNBEaWpzQCJjazu5C9Gk4EvPwV5Kha5/LS4dI6gIhAN48GS+p2zyGWwK7e8hBEK/rHKEmIOAxVscXJCZiXmEB"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.1-beta.1_1545191248503_0.6528569953144681"},"_hasShrinkwrap":false},"1.0.1":{"name":"umi-request","version":"1.0.1","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.68.0","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-terser":"^3.0.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"967c954c9e5ec25596c950077bcf671d621c6c1b","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-h5r4QWvJKb+BSA6VnjPwLMqXrYyoJcnrza8RLejGDIUcmvJ8hhj41D34e9ta7TV7x1RUeuAoubCD0OjcrcUBjw==","shasum":"20a74dcdaae096e6992b58139e305a145f382160","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.1.tgz","fileCount":6,"unpackedSize":31610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcIJ52CRA9TVsSAnZWagAAgP0P/R4hDGP0XrjzkqPX1MEq\nosLyNAfWjv9Pc5nsvIz67OCYIdBame/sp43l/NsBAV+7gQYSxUTuE7N052aV\nVXBVoflMUtR4U8pGG4JHHfXXvZ4uIjxmDrJ4exFBBgo60anb65ei5eha4Sbw\nlMb8hBPlvtyyq7Zo2LiC1vXr3HsDTxFgGuApUvqy2MTFAgbHIW1md8JdrCy9\nv8SuYOfUZRFN7zjua/AZrbb1m9DxRdnHBKbB5lib2U40xtQgx07z7I46aLL6\ntGWjtpLKx9Qn6dL7trGWmLtMxxO45j4yLXZOnCShnwcYGFsjv1QliG7QaqKY\noxU9/UB0Zd1lxL+lFHjknXWYPs5NIzI6DhKzz6NCoeGj5rdAT5nKYiHISmr1\nv6KgNaqc8FRRVdINIK7pKUvJaRIXZTQqCPk/p/XBs+PsYz3IvRgqwBYJhXbn\nFDmUAe2Y5YK9//5XbPidyFZ6D6NscycQE4pwg1ADsdFxxxt8hZsASYUrE2Um\nyI4XVHdATMjWfzoK74QiiZZLjK77IgvbNvGQEJ3R3uUZCwB0FGB2ILsiwyHY\ntx4z8wOlIcBpN1g0knW97Jnd0hbSU3d6fJmpAthfPiX2gMaoqrw8Z9+4Tny6\nzjW62vak+v4h41zNf9tLtVOzKuyrCsz7to3qcCWiW2YCMOKL2ZexIvHRb5tY\nhpl1\r\n=wyJP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxUTAUkYyb7IIkO5zTCkuaexxDnpXh+G1+Pguv16jwBAIgD51DusoxWXEtQxnmhP2rYtSQeaLnWpofCK1qWxL6wiA="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.1_1545641589822_0.6814211606202134"},"_hasShrinkwrap":false},"1.0.2-beta.1":{"name":"umi-request","version":"1.0.2-beta.1","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.68.0","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-terser":"^3.0.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"readme":"## umi-request\n网络请求库，基于 fetch 封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.\n\n--------------------\n\n## 支持的功能\n- url 参数自动序列化\n- post 数据提交方式简化\n- response 返回处理简化\n- api 超时支持\n- api 请求缓存支持\n- 支持处理 gbk\n- 类 axios 的 request 和 response 拦截器(interceptors)支持\n- 统一的错误处理方式\n\n## TODO 欢迎pr\n- [ ] rpc支持\n- [x] 测试用例覆盖85%+\n- [x] 写文档\n- [x] CI集成\n- [x] 发布配置\n- [x] typescript\n\n## 安装\n`npm install umi-request --save`\n\n## request options 参数\n| 参数 | 说明 | 类型 | 可选值 | 默认值 |\n| --- | --- | --- | --- | --- |\n| method | 请求方式 | string | get , post , put ... | get |\n| params | url请求参数 | object | -- | -- |\n| charset | 字符集 | string | utf8 , gbk | utf8 |\n| requestType | post请求时数据类型 | string | json , form | json |\n| data | 提交的数据 | any | -- | -- |\n| responseType | 如何解析返回的数据 | string | json , text , blob , formData ... | json , text |\n| getResponse | 是否获取源response, 返回结果将包裹一层 | boolean | -- | fasle |\n| timeout | 超时时长, 默认毫秒, 写操作慎用  | number | -- | -- |\n| useCache | 是否使用缓存 | boolean | -- | false |\n| ttl | 缓存时长, 0 为不过期 | number | -- | 60000 |\n| prefix | 前缀, 一般用于覆盖统一设置的prefix | string | -- | -- |\n| suffix | 后缀, 比如某些场景 api 需要统一加 .json  | string | -- | -- |\n| errorHandler | 异常处理, 或者覆盖统一的异常处理 | function(error) | -- |\n| headers | fetch 原有参数 | object | -- | {} | \n\nfetch原其他参数有效, 详见[fetch文档](https://github.github.io/fetch/)\n\n## extend options 初始化默认参数, 支持以上所有\n| 参数 | 说明 | 类型 | 默认值 |\n| --- | --- | --- | --- |\n| maxCache | 最大缓存数 | number | 不限 |\n| prefix | 默认url前缀 | string | -- |\n| errorHandler | 默认异常处理 | function(error) | -- |\n| headers | 默认headers | object | {} |\n| params | 默认带上的query参数 | object | {} |\n| ... |\n\n\n## 使用\n```javascript\n// request 是默认实例可直接使用, extend为可配置方法, 传入一系列默认参数, 返回一个新的request实例, 用法与request一致.\nimport request, { extend } from 'umi-request';\n\nconst extendedRequest = extend({\n  maxCache: 10, // 最大缓存个数, 超出后会自动清掉按时间最开始的一个.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // 集中处理错误\n  },\n  headers: {\n    some: 'header'  // 统一的headers\n  },\n  params: {\n    hello: 'world'   // 每个请求都要带上的query参数\n  }\n});\nextendedRequest('/some/api');\n\n// 支持语法糖 如: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// 请求一个api, 没有method参数默认为get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url参数序列化\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post 数据提交简化\n// 当data为object时, 默认requestType: 'json'可不写, header会自动带上 application/json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header会自动带上 application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', 如何处理返回的数据, 默认情况下 text 和 json 都不用加. 如blob 或 formData 之类需要加\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// 提交其他数据, 如文本, 上传文件等, requestType不填, 手动添加对应header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// 默认返回的就是数据体, 如果需要源response来扩展, 可用getResponse参数. 返回结果会多套一层\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// 超时 单位毫秒, 但是超时后客户端虽然返回超时, 但api请求不会断开, 写操作慎用.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// 使用缓存, 只有get时有效. 单位毫秒, 不加ttl默认60s, ttl=0不过期. cache key为url+params组合\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// 当服务端返回的是gbk时可用这个参数, 避免得到乱码\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request拦截器, 改变url 或 options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response拦截器, 处理response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n```\n\n## 错误处理\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * 这里介绍四种处理方式\n */\n/**\n * 1. 统一处理\n * 常用于错误码较规范的项目中, 集中处理错误.\n */\n\nconst codeMap = {\n  '021': '发生错误啦',\n  '022': '发生大大大大错误啦',\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error;   // 如果throw. 错误将继续抛出. \n  // return {some: 'data'}; 如果return, 将值作为返回. 不写则相当于return undefined, 在处理结果时判断response是否有值即可.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // 将自动处理错误, 不用catch. 如果throw了需要catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. 单独特殊处理\n* 如果配置了统一处理, 但某个api需要特殊处理. 则在请求时, 将errorHandler作为参数传入.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n *3. 不配置 errorHandler, 将reponse直接当promise处理, 自己catch.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n*4. 基于response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n```\n\n## 开发和调试\n- npm install\n- npm run dev\n- npm link\n- 然后到你测试的项目中执行 npm link umi-request\n- 引入并使用\n\n## 代码贡献者\n- @clock157\n- @yesmeck\n","readmeFilename":"README.md","gitHead":"3adf32ca2c1f42f2962a44903e8764ef3661b8be","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.2-beta.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-3hLIj200h/lUXd3zoDhpsfVYilgHa8KjqUNU+RDzmhNvM5xv+x4ZMYPDjrSYkwzIQJcM4vAQXlhxFFZPMtfFOQ==","shasum":"ae7e13f9aa181b89a28e9d9b1d09d7ec8375116c","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.2-beta.1.tgz","fileCount":6,"unpackedSize":31728,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcIkFYCRA9TVsSAnZWagAAvjEP/i/9XGJiy6I3tHprjdGV\nJcFkiKSAn9oSxgboSdr2ZxplpWBUZBJB2tuetHjII9bgold6R3QxXTpZZELR\nsQJdD4pItVi8JqaFBHOrnsocZJbLRF/aflr1CVVnDJgfX4YJH3oorQkylu+I\nVZRxyuWQeRTEQfpxz9i6LSdrxWqrzrJglAr0zhjDlZ5z078V69n08I7j4Zss\n7YKrUtitoeqsxpu3h2mEG7Igm4uWaHe84ARh1RiledA90EBEkBgLjU118OVE\nkBmIA0W25LXBLRX9mHTZb49efo0g+VoZe5PgxRpS+mxa47he1o0fCBE5NGLY\nKyEefeCxJomNAgitvV1YFy6shlIOPGFVeF9x4+PkFIVZ/mfn4etJpoOGtsHI\npUbDre2CWhm+yFTCWe0NZmJxoIw2F9U7Zn/fpmO9MLiIIBI07lVjDtfMdyj2\nRA2xpZzJxoTmjb4wF7QEqVD91AqqniV/emulA0msEdqTMeO2wLwfz5SrQzv8\nRFNiFYIBcXz7T6IevlVOhdjO4DOZJdWuOPo4u0M9gdT/1rrgtOwKHEQgnNAL\nIv0TdMfFWKH0L1C0kTsRDaJoLsw8gmYjklT8DwxjMgo8exLUHyJDYw32+c5q\n8mDPkHJw7k0JoW31vm646KIrfSLKdkNi064oWa8CVSd5lPBmd3ZX+wwXjdpc\na7qJ\r\n=awGJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDMrgyPw6OoLoIt8hUTFerMzqJ2vhlv3art5XwIotxErAiEAnevIYm8iBArquw95FedREU0oc4gqTk3bQywsrHt28SM="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.2-beta.1_1545748823531_0.9154776996101062"},"_hasShrinkwrap":false},"1.0.2":{"name":"umi-request","version":"1.0.2","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.68.0","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-terser":"^3.0.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"d0bacdaf1dc470f8c8d93f2808830f8c2009608b","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.2","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-czSEdVJ9anIsrmMD3ooWXxWvmtVeTsCFEdyhstdGm6RsYVPyxEtj58B+LXhILfT6jNs3HB8E/plZb7p+RTOqmg==","shasum":"1465760bd659dabf24bff82b235aaecebaef5075","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.2.tgz","fileCount":6,"unpackedSize":31725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcIvctCRA9TVsSAnZWagAASNsP/14y/aAsQO3RJO3DwQaq\nLHbUzQVSQEagFLX3pTXftjIaLh0hIbGmrBxlDY657Eqsf0svXM9pyyhk8WY2\nLF2cN+nbn3WNmHq0nKNo8NO82PyOoFx9YkTh36TpTBUKGR5WkSBFVsj89fPP\nXAxMfHcR8KeJ2cckYx1spUDeYfTe3CxG9hFqXML9GiTavuhYtseRKkjaauhc\ngBZ/QZT8kR/jT9F6XJnZ6cjrN3eIbpGMP/Ste0/vZuviDe8NBQ+7sdoLl4z4\n4VMeP9a9D0WxXu3lpe6phVzR3aIMCdLJPCM035D4kYnsJty9LYV1STNHrGbH\nMQk0AKGyWepR1G1WDhYxLiite6xxxHYXOEEGIFOmyqlk+kaa45f5SCs4kFlS\n3EUuLWUC9CAWdHLMsq09OiUMYax9xXtkswLib30Jj7jxSxxfoBZ6DwNTsoVW\nBM30Q27e7D3qoG7UukvzuZj1hgRcHSoSWyk0MAdoAIKrutVs7KyLEbW3/PNj\nRtvP8PVaElbSVP3ktdy8RjLAsGJUjqCtxvRYcUvqlkb6V7NyaopwBSzlqofH\nXkq3daj4gS3bvmTaiXC7LVeU5fCoc6D1obB+bmVJbrCywotki8nWaarI5Ixz\n6FFH2Yp+w7Qu1ZnOQnannn2iw+uwJfaXqdP0MRZsgxN058V21iBUPFf+qf2S\neILB\r\n=eDuY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICg3IsfWL3yiqq7fSNPohjsUWwRnLJL7ckQ/N+lhA0oZAiEA72wL/n6KTgiYaiP1nxCeVbS6yHp3KefgxAY4zXfiDJg="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.2_1545795373082_0.4220408385883583"},"_hasShrinkwrap":false},"1.0.3":{"name":"umi-request","version":"1.0.3","description":"网络请求库，基于 fetch封装, 旨在为开发者提供一个统一的api调用方式, 简化使用, 并提供诸如缓存, 超时, 字符编码处理, 错误处理等常用功能.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"cross-env NODE_ENV=development rollup -c -w","build":"cross-env NODE_ENV=production rollup -c","test":"cross-env NODE_ENV=test jest","test:watch":"cross-env NODE_ENV=test jest --watch","test:cover":"cross-env NODE_ENV=test jest --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm run build && npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.0.0","@babel/preset-env":"^7.0.0","@babel/runtime":"^7.0.0","babel-core":"^7.0.0-bridge.0","babel-eslint":"^9.0.0","babel-jest":"^23.4.2","create-test-server":"2.3.1","cross-env":"^5.2.0","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","rollup":"^0.68.0","rollup-plugin-babel":"^4.0.3","rollup-plugin-commonjs":"^9.1.6","rollup-plugin-eslint":"^5.0.0","rollup-plugin-node-resolve":"^3.4.0","rollup-plugin-terser":"^3.0.0","rollup-plugin-uglify":"^5.0.0","typescript":"^3.0.3"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"a1df53ba08894b41eb075ae9b33437475270494f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.3","_npmVersion":"6.4.1","_nodeVersion":"8.11.3","_npmUser":{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},"dist":{"integrity":"sha512-NjPc7tHkEAaikNoQPgJYYAGw8A7La2KRiQDHrrXD7WQZ4dVnejoGhZ2iP14PANCEcZrf0OkxYyv6Rcd2O/wi7Q==","shasum":"3436dd5ad0b8c5679b481990ecddfde25d697389","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.3.tgz","fileCount":6,"unpackedSize":31772,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcJLaPCRA9TVsSAnZWagAA7iMP/12UoJIAIMemzospVyuH\nX9QeYuW2m4ibFz3OOD04FRRX5ckYVIg6BZVlJYDa4FwyA2rZLDzChkPHDYcO\nYF+euNEekJCa2+4gN9Cy8ovJiXF7/Kv5JQUZJpRrlp0OIlXAonekMPhzAOG2\nMrJ/E3QOSRvr8EKjTMbLPgi4KtTjkgUXQPQFD36p2HQgRjxAWFHiOJiNCS+p\n+B/hH4F3ZlPvMHXfCB4gdBVygbo93sHj5yFExjc09w6xzx9PUjoZtct9/5zL\neSOZvRN/P6f3riKM0MUqFiDSVDDigPHM0DiEhz7+wzzAlLJ7xr0pEdPRqvCP\n5lOiaRMewbr/MLr5UP7Dq5Tm3YFfscDiBbJPSnn5HaC8GoXxnBJlaBTLTtPw\nFozTSyvVHVi9wXeYU9l5Aps7pJyzqi8uRBvvtjKzyRUYM/qw2vvd/U/61qdI\nwMvFRFVlcD8no+KjQoyVj+K20H58qhp+lr/7P7Z2R1KRhIg8uSAP/8iTWws/\nz8WZrv0AqIobwu3I2btaBLnuHR4L/eTa4RT6/Z0RntS/Sm+3g8/tePEq9wmH\nr2lkKqKQ5wvHaaUOwXkI1XtgwZeFDeHmob6yAqf0jYV6m6q2NSMNRQiF3POl\ntWwXk4tzr0a9pn+oykfHQ9nD8S8B+qTclD2+1y1DQkYWb0qZOGw6mbO7g9pf\ntqfY\r\n=tNNM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCh67a3Hleifq0jDg/4yz+j4e7rsqTXp0OxJe43EXIV6AIgV1S0aWTQAgtRcojBxjX5y1WTZY+J1r13CF5fV1T6zCk="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.3_1545909902501_0.9839887803480134"},"_hasShrinkwrap":false},"1.0.4":{"name":"umi-request","version":"1.0.4","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","typescript":"^3.0.3","umi":"^2.5.0","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"cdd12e1d26d1fefb1365c334bc8cde20744496be","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.4","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-myD+/wx+3KUrFWfHKvfuZv+EaovUazj6xvISxqqUHneTlVmBeBwNCvss0rOjwVdxAMqpLzoRuHY9S9occi4Wsg==","shasum":"2892ad6572deab7b40541167916c8e78d272b3ae","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.4.tgz","fileCount":6,"unpackedSize":56361,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdhJaCRA9TVsSAnZWagAAeTMP/AkGesdo/JYm3sBZm9kV\nHF0HNE1GhfhksV6z2gbV8x522EnTZnOZjqtLkGjgN9AZ8lbe+QTJTdALnMCa\ncIqUuesYtwiIHKKwTvxKWEVWAoyarzCrc6yqd2nVCNeVwnPhu1wjR59pPL5y\nCiDjVBrSOn+sE7+z6Bbe3uAOckUN06kFjqr4Qvu1yYYfJqDS++j2PssWfSQW\nlRpjEizjRdVn+Xbaz1OIwNagj7nh319xQN42PTlrzGBNaWLlPdXWCVl9wKms\nLki1ZZIiKZABzmdeQObN6De2FOT1M4r+evp4L7UkfHLK/CQuPErd9sR6AGfF\nOsgSbs5MVlRWsF1kdT8Ipw3LvxKNjF6QFpZcm3wgEekUrRhDuETkfnn9V5rb\nVEOeLm7oD+IRu7fSyEsbAjQ3A/PvfqOOJVMkejKxrsS+KE3Mk+KQhUOsWRFv\nJBSa4WTwcH7u22tCd8fS7cfOdg2kTOxpWYyU/j3jwgRx/p+apTni5IG0DGY9\nkOOu9q2RF0Ew/3BGRUtXLbCG9ZqGAvPGqOQcH3OIcb8tYbWfIcULaJjrn7v9\nfW08wfAvZ8RRs8Ws1fu5nFDriNBMUIsN69KDwFWr3MjZpgAlzDUimvGu3a6C\nPGbd8c74ZdAwK/lAHDEhSxVcMNdzfQRwuqFDY2OTmiCCuRoq50SrSkojFUZc\n4pUJ\r\n=TccW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDtN8A2tl8z/dg0Tb7ucWnJtYFikvMqgRgDf5RH6vqhZwIhAIH8ORxX9pTXi3PFj9oJFRZ4Swykq+2TMPj1nJs95UET"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.4_1551241818043_0.8079176010481854"},"_hasShrinkwrap":false},"1.0.5":{"name":"umi-request","version":"1.0.5","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","typescript":"^3.0.3","umi":"^2.5.0","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"b36dd7dd68e6839cc65b34ce21bbe82a172511d1","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.5","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-CwY5C/SFo5s/eW0FzVAiYGxi9ypLn1HlNGlyNu4bUV6XKkwXWMneT/+mANRlkv6lyPaEEKSo6v/E6PP2FaGn5g==","shasum":"97a45950a1babe3b52b67b1f118b02de786ef2d7","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.5.tgz","fileCount":6,"unpackedSize":58606,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcmLXBCRA9TVsSAnZWagAA4n8P/1/ga1MNUQvIFzOoKeAl\nneoUBjxnLVnbd6+6M1TIjgrnaHIkprZkvEHNy0ZtblCK5sRf+xy99QlQyH6Y\n42q+ufMMLqjX3G9Xr1YjSpWwC+s44mf+sJH3pn8pFJv0xKqUUQWtta4tlrJr\nrx2UXSQ/eJBcfrxIrKsnvEDhbSLcebWGQ9rNHLENTDR8JF7wvRP1F2DjzGpp\n8sJv6mKXI9MwrdYoylFNcbsZgPGuY6jiMqqdn+5d2reJbfl2GXe/D4rfWDeP\nlitoNOs0Oa1RJWfxM85phIv0bCdgyuMMHx4uebyHSAZVmqoX/x3Rqn49Sbpq\nqvnJB2GsJaXOg9Sp7fL+1g1VkaA6sfMWyKA8WkuHMP8C88H97VAIqenOdy11\nnpiP6Vypswsg7eElstW9aCcNqUIlCN+dlZCCDQZypR5K/tNBxqShfB7ak7iQ\nleT4q0ICbRPhLqyXOBP19b6ROs6Z9Uoat+nKHhKHwP4bchbBHrdkNHOQIbka\nq/3PeZ0Jr2BJl+c4P7zgDvZEZgoeHzCTT1uU68YglJhRnYWKtgGl8U09zg4z\niQsrx0I0N13dFBo6laGffq1z3JWiWNUPQOstydTNDN/Lj3cvkuZCIaBXg5hu\nMSbY6JouwukmxjuJsLLXx0LnA997uNwdR6nYyrse83zEiR4ulO4ZhruLkYJY\nsZmZ\r\n=AfaK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDz7jT1b47gqRhxsN7WBrQdj2A5e/BaZOxz/h0Vo1QgCgIgaNO9//ANlME5mv9pAxIH901PaRDeZ0wLsIlTeDc2sII="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.5_1553511872757_0.05548079382173188"},"_hasShrinkwrap":false},"1.0.6":{"name":"umi-request","version":"1.0.6","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"eslint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"lint-staged"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint":"^5.5.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","husky":"^0.14.3","iconv-lite":"^0.4.24","jest":"^23.5.0","lint-staged":"^8.1.0","prettier":"^1.15.3","typescript":"^3.0.3","umi":"^2.5.0","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"src/index.d.ts","lint-staged":{"*.js":["prettier --write --singleQuote=true --trailingComma=all --printWidth=120","eslint --fix","git add"]},"gitHead":"7c4f8820c1bb7c4fe2f22a23fb6b0b17603c21c6","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.6","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-tPNjqdFObEZ9NHneGNYEI9BbLOZYf9zCWR5gNlA2+6FJ5OWlNsiuHWQwu09GCjw4YD8d3CRnjZ5HUSyLftz11g==","shasum":"18d7cacaf402a7dfee646ac7808bf5caf7f2604f","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.6.tgz","fileCount":6,"unpackedSize":58847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcrtFzCRA9TVsSAnZWagAArfkP/0x3/kXVfBkmDjvrSEBa\ncK7Pz9hniQhE6IrU7F6rtsT/v0PVq8s+eq4Tz2Khc2nLBLz6UcCyiDl1mMKM\nRzebI6gOgW0e72pqlHXNr7c1z60fDq62s9ejLORr8EMA7uUqrimJ5zobuL20\nGKFG2JzOosYsQLtgInDr8EabQmRfCFVxptwbanEytNSmil5FZ+bUPB3Jkxky\ngrhaW1201rb+5pLh77IFsv5DdKcvzU4lOENdwuB7oKnuOaZVO4zqYUGBgbvA\n3dQk+McFw1238bNjx0K8/Zykogsc+y2F9NOsZWt2u5VD2n+KO6sgXXoK72DW\ndxm4oRRFAkwjAdi/KWTCwdVeSGjcJqW7/fGDfkipIFktxCol9HnnUDQFfoKe\nyJ+Vt3N4uT6D5dFXWWId7o/BnrbZMEldkuQo13TwICGTgG8C8Nm6EOQtwv/F\nXOzQh+BNnbwecST6lBdpkLu+TrrOjybn3S+nPLcu1vQK4AF9lBFBFi9VyjWO\nKEnfiOdYnR1wxnbXdKdUTvUROgbnsDEOBifIis/n9vt+A75BOiEcu7x9717B\nUPyv/6zOPpnyJ+YtpTmtEjnHhXYttF6QZMHsointcbTNQTq4Q5ol8kJp/IOQ\nYberlyM5oTl9snkuf/O6T3yn6YCxVs/JO4U+PVWNcYwFBWzT1GjfHSi7nOBC\nBJL1\r\n=SCVW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJm79rkyhRH9c4Xz0WC/LY+7hycHpqXEANiG0RAGKemwIgH6sKmYJqKlOo5PppsTJkq4PFr0uK3w4xX3UUoxZccs8="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.6_1554960754213_0.4569809761721262"},"_hasShrinkwrap":false},"1.0.7":{"name":"umi-request","version":"1.0.7","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","pub":"npm publish","pub-beta":"npm publish --tag beta","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"c10a9b5644dd2c017efb33b352869e572f35fa47","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.7","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-jnQ/G+3UF0cT4PBuMqlvejQLQCS8Fapf3/5GiR9k51sNfNH95lLWJYLqUd2PBtcTlxBRPKsSy/nRgFLdp0IdVQ==","shasum":"54a28e7819202b5e53930297a6b66ad500e75b2a","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.7.tgz","fileCount":6,"unpackedSize":58759,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcwE40CRA9TVsSAnZWagAAOHsQAIXpk6wZtmI0gwyL8Krz\nLkC89cvEoR57fEddHppzcnxQ2VkjSvnY1YkikVW6eUWFEuuSG6fgQFUZByvK\ncpSANm2XAVx1Tzj8vbFuCVdQGbMWsXdvy0Eg3wLiAnCzVeJ0HEer7QRZsX69\nlIqwnsiVVvNw5TL1U6qyht6BHcTcBc5baHkwl4q9S83jkjDAow6P/TOyyV8A\nFyqlRURWNflny6Vz3/iDAL+SlK3YSPj8B/7QAl905C85z+CwgfI4+yQKJEeW\nWE39s4NQCSiMg0wz3MHH7ppW2HVYoa+QZFrp63E5q3crtxGHMbidx81uKzLD\nGQegc6CEog5chPbDpCpTk+Xi8gr0xzSPOAtqDm1S/n7Yd/ioBRnxDdujx6+Z\n1XCHieMUodlkopxOAzxGasnd4O3PtczmSegS5JVVwykufRr2q4JJ3uzxY2a8\nrik05DBOks0ZFed/PIge4oZxgjURUMvyiLgvGYCTwMvyym7ks/+1eNBBF5fE\nf3dRTPX8PvYPLng2JD4A2kf7GhmUWKew15Sj7JGvbQ1AO7gomy2lHXsXnAGv\nubZurxZbGYYycE9X9kcug4OA/lFtLtM8EF7nOyoH/yoLAfGQoscwQ+kUdYvi\n6g9QDn5mnXOgQje1MXt0rvPhcGd4Q/HMS1VTzc+Op4HJz996MFt6nxwBn56f\ns1F5\r\n=oWHk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBl+u6SS4OlBZWMjmkd/LgiuV2Hrq4jBcRbgPVEKwMVmAiEApXETD3C9ZPboL2P4Llw3JYrj2CzVtb8C+i6IBdOobHk="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.7_1556106803259_0.41441685876972256"},"_hasShrinkwrap":false},"1.0.8":{"name":"umi-request","version":"1.0.8","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"75ffc1449f25888eebd4d1522047bf1591451fb5","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.0.8","_nodeVersion":"10.13.0","_npmVersion":"6.8.0","dist":{"integrity":"sha512-7s3BQvoTW1CRBY6TMD4odJPcfvY/qnKOQD+Ckbh+0+e2HBf10RQE6L2X3bsiJOqn+gQ/cGX6ZgRgHFsYJdhemA==","shasum":"284e4dd83483453da9698ee1b4ace386a318d276","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.0.8.tgz","fileCount":6,"unpackedSize":58951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdAHSfCRA9TVsSAnZWagAAWD4P/2N5JbM9o1tRcJHqJXdV\nWpL7pGCgd7ZNqTc0xhND8Dz9tBZLfPEBjYw2j2e0DdHQVk20yuGml80B2AoK\nEbDj9iyuUvfDytsqHF88ZA1DA8ibrq/w5G7W6lgn/qEzyzYZQGbLUvhNyGCx\nR8PhhfdJ3GHAu27+gguWKM56K6GCcq+8z7B6N0ujNOzNjt9XplqyGAw9CC56\njoYDqLb0b7mfwjps2xd++OAhLIJouTSWTUYWmsAJYy5u6LcuPqSVZrZykxSi\njsVirMOx5Ddfd7erlpTswO4+tH2//fD0wzmkIURCeHQkZGrsJBD/CzgQ75iw\nvDWSqT02pLym5w5UT7BBmlAQBtk7ROQOjf2jdg8Sfk+fW7E+MObL/04xQb1o\n/ggMyEzJ1H/loKHskabcTmlpolcJ2iB81c1XacnkFwj/XKiJ23sAuOI+emdf\naK8GfnCjzq6byHXKwEQMq9sn317v3Tt+P7BS9AQ2S4Tu9FH/bnzSO+rehsKR\nUbcvBzmez1AB0amSEHqjHDPIoRGLYtlwyjvns1vyGIA2f8ld36U3pZtdqqxU\nokbyb+Jglc62RUgjFRSPlwJ7+MfScaoNALWjJnNADBuYuS7bzF3fDQEMbPbw\nX76MwyiliRkPVqixM32KQuf06Ee3eA9oX7Z2wmW0Q+moTNKl2OZ+DUGh0Ujw\nt1e+\r\n=N23S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOqfgBoMdVpBXjt2IwjZXvy7iKU0QRfkpfg8aHOK6irgIhANDOuYzCPlq6dMop28sVEGb6haqKeujDXHpgDSSOqEBd"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"_npmUser":{"name":"sorrycc","email":"sorrycc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.0.8_1560310942453_0.4158755580333082"},"_hasShrinkwrap":false},"1.1.0":{"name":"umi-request","version":"1.1.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"832118fbbc20d86a4c4f6871bd10f85d8e5f4f49","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"clock157","email":"clock157@163.com"},"dist":{"integrity":"sha512-eFigydsyuDxxUh1N/GmslbskJz3D5lhUFcjVo3ohllstjC6RPlYnE8VKLVcpK77r8mhZGNWTTha8Co+ozhiLwQ==","shasum":"09ddf8f8b012431441f08b4b33a1f6d03f5c369e","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.1.0.tgz","fileCount":6,"unpackedSize":60141,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdJYgTCRA9TVsSAnZWagAAJroP/3FPgcUgCdzF+9TTOc6y\nzYb6VT2QW+xNiTR1kj5uV4Y1yzUy0a6XPzrVvHsO4s1yDGzkGlIyJ7VnCdpV\nVMPiel+Pm1e8FaNgkPIzmLr2/n87T0MVa9CMmqY54Cn0oV7VFXH/vbIwEfcC\nFZay5LBy5MIAU7AGTe8k88YyiFNw6bzbzwFa3f+GQIVSTig2mN7rhzLaDNTR\nteqBYuCN6Pu7OXKbdsPHmjt4T39XLBb2Stf90a0L2fR2R1BIitE6zJ5tM0VE\na71l7qcUQi6rTvj+M9Vi/uCHrBZ4hxruVXoUAS/TPHB6VDhi1mGMZo+6mH+J\n7T9MPWOIqMDdd0vk9Zr5/VMTt92Wg5WmUJ5nC4hZoIND4m2mTSh942cSN3Cw\n1LmjP7YCmFVPWc6Mn7hcFRIr61eDm8b2fvXcWXj06499e4a9++pLSWiXfgaU\nUOtPxrqVL/B0egB5XC6bHB2NYuxQYSy7aD9LJwAwCEbiyR8yTx3KUjxiLIrM\nYTG9BIgGQ1zeqy55JCnJLqXhh8dPXzZrUcfmN9AaD4K89lvkImoMtw52UdNt\nr5TQILXvdrFAiwW+MTNVpqsmKcHRW+rZBlthDZ7iN7a/s9PzCKAD6qIeaTdh\nBJvMnsFMDK9RhjZDjCOtXoV5c2IAksmNRwr1SVKJwYkwrEfBJdSsRtHj63pz\nOBfG\r\n=xPa4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFDG1r+4agTXOv1gPLPVtZ682LoVPMX7NdL86yJyDzFRAiAN0kPtKF1MLBwtlJK4H5PZ5/gBEHtstkNw0h36Tip4VQ=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"yaya@uloveit.com.cn","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.1.0_1562740754445_0.7885714528218195"},"_hasShrinkwrap":false},"1.1.1":{"name":"umi-request","version":"1.1.1","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"b0dadc2e9a8412c2cbfa35e58b04983c533dc063","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.1.1","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-InjczbBLu+PXn5ctk9g+81edxmompkWWfZQCpryFKbOxTTBzUfCvbldxTdPt26AWclIzsHKYEk8xEcaSzXEPBw==","shasum":"e9b40001cb1deb649c4501fd2709e48c5aad43bd","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.1.1.tgz","fileCount":6,"unpackedSize":62665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMZPLCRA9TVsSAnZWagAAAJoQAIF+2GpenI9JbI4m6jTS\nVJ8bRkP2BLEtsZz8Ki9O+AM1AlQUpj2EQTg7ZAkkLgzZm6hgDgZ+Q+ResMUp\nc2JbZFOsWH8tFUZEKzj1PxzttkjDV0B8ejD57QA3Oc/Lh1MsjZhc2rqUYlgg\nLbXlFgxqlC+QUenITTsXaNiMY0TYCSfp8JMvqGu1b+u3RRLAC2rD8pZ4Idyp\nmAO9MtVJAJ1HZgh7by1Jk9hTki+W2iQ+DV1XtpB3e8Ld32nPamfAprIe3Mju\nd6D5aULmiDv6Umb7Wp8BZFOVrtN5kB6c9a+LEMMRVzomTA1uB58nhlioT9mm\ncnNNzneST+txVSz66LM+rk9lrYfLeg7+q2/OOMBHHCXKsaReguge3j54QIYT\nPfXvoQTuWzSoOs7vtDCaNnEXYNf/wWBjxb/HNqldxj1WZmgDgAZtEUyhkBfz\nkz+g6yVzzf0A30w8sFGo9esOA2buJUSPYvH8PB+3uRtwD38bc7mL5ZUwi3L9\n/3ee5KSurvuY5iR1StwXvChHj8ebFYH5XgYR0uXkA54ES1Oif2LNaauNmlxn\nA5QjruHyYGoD3GOAqm5mK/FmxlFhkieAubFXlbnxjvOg3EEYMnPevjNxsGe/\nzVn+KdvZlr3koJl622qyPqUzmYVEkUrGxsTb+ep+JI36lHtS16JU7mHU82nQ\n31CL\r\n=/05t\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIANvGK4D6lyikwsuSjKF2LerU9FoV6/4AEtjRWdV6wVVAiB8VbqxlvtEYh2iutc0T9eWtvFvBjVokl0uldri8hsmJA=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.1.1_1563530186227_0.6979741365196044"},"_hasShrinkwrap":false},"1.2.0-beta.2":{"name":"umi-request","version":"1.2.0-beta.2","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support for class axios\n- unified error handling\n- middleware support\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"7f2fb489ef988ab290d9b41948e23089412d1ce2","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.0-beta.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-KT/VduUOexuNlfdpGaihoz/ybo3sSt979y9Qet+ZzsxG2jfgxVjmXVnmpHTqKeYKvnlm62BuWknEuhD8EKXpWg==","shasum":"2c1c17cc548311a1ffd6794901732c4beddf74b5","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.0-beta.2.tgz","fileCount":6,"unpackedSize":63757,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdNw5ECRA9TVsSAnZWagAAyIcQAJFHBkuaLkHua4z0ZKXv\nuhjNOxz2lR7WgWho7gGidEH5iAcFiXto61h3du41scjc8ylclBf5dJ75i2+B\nmpUSXZXDyl/NiVGYGE1St5kEfUwamjeACUEBx3zkj00wcT5GryDBtspCnhZO\nUFZtFcMxkR3hDKiE7vApQOyCx2157sTqtkSvJgV0NLmW1dRya96tWBSyyZuC\nBf6rtr3nh7rfIngN8LYtc75JL8vOFzbBTthInWPrXTcOmFdpEYBhqwn9BIGw\n+HDfBmCs6fIFfS5ITkbx6L4z4RVZsmT5mYCjXumYwEBWq3jNjzeTZGVynKJ7\nCNHYtX5zHFUjP2AHvb5HzRXaA+x7Pt6Oun6tylNJgEYzAjXsYPHkml52ii1c\nOaZKTf8YefphwYO0M4MbKyDI756AnevvPJV+tSuE2pJVup7Sl/+Q8df7FOrR\nk1yaVQJ8RkUF/6JLj3QzyGoD0mKpSplZ2oDxia6PougZj8kJd2L/JBuAan/m\nyhtrpkTaykY6NUTTRi5J4FOs5Z8UT2QiES8+9SfI4WYNIU53A/z7TOI99Osk\naj7VI1ixT7+YxAQ2YMwSW6sJ78xqS0oMDdDuIxHfibNqwexPBCTpkazYo6TO\nc+aEzT/ikENrHEyxX5xjH5ch/vX76Pxix60LbtfQMJcTt1/Y0YzjGNLvc5Np\nL9Zz\r\n=3e5F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICY/6915Hg/Wc7wz4Cxwju1Z4igRtgtgMqtb+n6h0DUNAiBfNkfdjOrCR2/bXGCCUEDPDxY3G6HTFai4KcL2f3kQzg=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.0-beta.2_1563889220307_0.6672334893784955"},"_hasShrinkwrap":false},"1.2.0-beta.3":{"name":"umi-request","version":"1.2.0-beta.3","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support for class axios\n- unified error handling\n- middleware support\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"1244babb01c8779bb88e954c1e141e52769d3703","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.0-beta.3","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-0C2ZN2TehEjXTEjvav3pbl3iArqUAcMklDOKTIj9txEfhhOoOrSvdvZm4THmLAapKslLE5szV3kZ2Qowj86yFA==","shasum":"6cc969c9f04e792b170a659c8c0d16fe6f9597a7","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.0-beta.3.tgz","fileCount":6,"unpackedSize":63755,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOBnfCRA9TVsSAnZWagAAwrIP/iXCyzzz81gwaYQsaF2u\nwK/BwDR0Xm185/obF3/SovOho6Uv4KbwsE0Zo1gmhtlcwa+OOJbND1pIMr8X\nwstUKfy7xHs8TztqNw5UB9Q/O8k1qtTZcoL9yrwoxhw9YX615c8CfFYWc0GL\n5XC0ujB8SNaxhQzoskzJViT0S+tng23PCydeYshngsMgWodt7nILynAVuACg\n7hjR1m7Y/H33OB14P0gOu7KeK47ZsXZ6s/uP1FgFfjn0dm31sKqZh44+u4fd\nn63nn9pD76p8ObaWGXYp7PLJAama42xNuYj84V9c6tVsEHu73EgUyPeTZ4T5\nl17Tfp5xDqdp68GZSx2YBURAR6qqR1s92YhTTKcmYVfTboALzOyBYRJitgDY\n+zu8rweUoZYvh/Mmn+jCCZ+gIwKEfZngdmDgFLN24V4UDuQHumd9t/e48xrK\npCQipPKxt0o9GjaaV9rrNNjh8tn4P1gWBU4T7gO87Aja1WHigyn5B3u7i8Sc\ntYfx/638rw9yaCZuLP+eTqSe5hIiU989PEmC0kJbDSifL7jgn0XxS90kcc79\nvSW6mrcXj8i8Lf/dOs5qhuTmWfsPO5tOfWDlJwEoR8IjuWTVg5D6PrqOCXj/\nlS2fawQEX4v5V/PYjQeqKwauP7TrMzILdwUJXURmZFGnGTIameMh2bDpVN+B\nQkGl\r\n=8w3F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCiLSyTX8t19Fv6YrARjI3sqk7unb+9PPXjxUuYNL47XgIhAIeasUd+iS1m2py4dDRbf97M9oXpZ63fAVvs1asplyC2"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.0-beta.3_1563957726881_0.9913331240519168"},"_hasShrinkwrap":false},"1.2.0-beta.4":{"name":"umi-request","version":"1.2.0-beta.4","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.5.0","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support for class axios\n- unified error handling\n- middleware support\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"6fe5b8eaf541895f2ecf67d7514e2b0f9a44cdeb","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.0-beta.4","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-L5d1RrPSVSQhJXJIGcc+Pu2nNhKkI+vz0iS/xuLwW65O0juUyVpIO4YCI1b3qxZy0gTos1Bg30XcEH+La9XKTg==","shasum":"38ba0ab1d5ff8b7fd1ea2013a616197b9e7d3d77","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.0-beta.4.tgz","fileCount":6,"unpackedSize":63485,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOElbCRA9TVsSAnZWagAAvgYP/262Gc2uOMSqicKi74+k\nOsMh0+u/XxoUi3yPzQqTOo1FB/uwhW4gOUj70KzbPW2pnz9WlYwsdd76xLiH\n9TlCgXmMM279KjQfjclOvuJw0ExPfIBBW5O5LAlB7qhuCxQE5Iu0nusm9esq\nJogbgG+Wu6wQ2VKdyvaCMIIudGJSGdGKpCbE+ocoHubyNSylWlJNM847Ur5E\nznk2zovOuiqGUeAkr6Ale8i3DZPa4hnSeovtB9wH+nt+nITKhXAOg9Y5vZHz\n11Lx6e5MrTGMfFvaIegsrKQOcQ863vDv8EtSGkfpyuOIC8K/KK8iKnUtoTjZ\nJFokvCJkwNASixVGDIZvgqOhScLGcHkIvvFaj6MdG5zA8zMZXat63XjkEvoF\n10jxP5+yrzUYrudBohiIU/0ThWc4fiVAQzfoVatz7oQdvyMq3vwsZXdw4QIC\ns0fg3XWXGcXN1npWo0N0zK5DzIBpgiKEgDTA/lOYx7s6FmLIS3TmvJG8FI+B\ngFan45v7ZtEidY4+Th0fS18CT2UthpeoBDdCf+e1od65Z/9gVfIc/c0NpGjH\nst4QXT7yah7JGghtvzm/sCC8vF413DXjVLnYLCqkLmjH/SkO7CnKoCUCk2Co\nDcV3ZrF+j4OB4oYAR0LVZsU/DYVieneT1fsIsHXXoUsZIL1wHMDCXWPeOajn\nfwft\r\n=MHTT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIETB+9ae+vCG8pAHVpwkXMtlrd2o7/U17e4eQ98WJYzAAiAjksKHpw1WmEuolHy4zI/9934ZDsy9Y9r19QBZ0qh8qA=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.0-beta.4_1563969882855_0.00783728847288745"},"_hasShrinkwrap":false},"1.2.0":{"name":"umi-request","version":"1.2.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"5aeef72a815dc7c7b649946af67b533a2ce85c39","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-0n5gnfAOol1DCtft5//I541cGDfeD9AtXgZMEn2psnIX8Srkh7yPqhcXRgJbk9rJxYUDs8D+EjBni2T36QXiXw==","shasum":"03ade34b8d6af7a7e6fc3ec35557af33d41f6c72","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.0.tgz","fileCount":6,"unpackedSize":63542,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQUD+CRA9TVsSAnZWagAAr48P/ReBrrQ6vzpwSgwGkSlP\ncYMxgIzwDKJBR2+syZsCSAsL/3O4Pb4I8lf/E2ZjKnKSgD92lac4VYGeDL4M\n8mee88kmu6GWK18WsPYPMvWNt9WdtlI7Zmlu+Tc+Ff+/DK95bkwpcHTbCY/7\nlHBG37mJ1QEHYSwJwuYP+XXtzGH8qInyrIiA75GFVSjJWA36xjyEToXr9kO8\nGTbqxVZZ2nGUlshsLUZAzu91OwHAfOTyt/93MxioJ7bwWpsAp6GafdvQpkxN\nN3WsHopzZ4HMydjcpdC9kjE6EeRBk5/XS4qThMtZNaS1Mh4itHhntNEBzsjE\nw0owf0rzTu1n9freXSHzBLoBFFutJu8T5sgBKQbeuF/FZzYF6vYgmEDiN3ud\nmhZy5XrzMHbOuZLKNVUkxowlPmQs3PLVtQhXzmmQOr1HxGPcTM4ASrj7M1/A\n9Gu/i3JBVoF/dadbFJzichpEp+u4u5s4K3W/H7+oIDF6aTRy0+JBumZJ1QTZ\nNWGdDB/ogPhj/vSfg7tDliPhWtsq1sbw+6RvMIo+fE3afg/1vv8huFOIsDeY\nBtTeqVkVQ9WwHij24UVyo+tFQWjFHuZqKibZx96dAkPZ6t7408z1vJrMGsHn\nsozbGHFHdqQxX8j5MShMcGLo9KFhcouCRqaSqJcPMOhbD3R9KmR+uZUvNHPA\nYxkW\r\n=FadE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBKsXOtb8KXNHYen/bszq1MLR1UjADX45LkzDZ0qXobyAiEA8akxD8qf1XmsYTAMkYRiCKuxH5hVwDMtK9KMEj9JEpk="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.0_1564557565233_0.25488170915963093"},"_hasShrinkwrap":false},"1.2.1":{"name":"umi-request","version":"1.2.1","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"39d05578c8e028c8c0fe97dc12dc21ff5ff8263a","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.1","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-c2cHYbXSlmXZBje/Pkn17WACbU/UCUHKgS1Snwjjs5om7SgQ18FApaSyp5EToKcXqIUfWjeLrmGq0r9HjR0KRw==","shasum":"397f1387df6b0b38e15e834ba228a541ae56a4f7","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.1.tgz","fileCount":6,"unpackedSize":63518,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQWeSCRA9TVsSAnZWagAAVvIP/0d0dZWtOEZ8iCaZbOnH\nA9j4hmuAZrPQS0RIaIR1kRL+iD5bdY2KCS9zKocfz4pFXa6p6ItNcvVO8tzh\nUCAXjVj8F5Pe4Ycp7raSmmGJEIYNfQpCwb37blu31b7VYSNhXm7DdUgT0ViK\nC3BEWgYo6WfKKj6Yz759ppyp35jox4+EelXcOAiytrPC/244+2TLOAYMfH1x\n6sLefZ05FHr6iBVZq/qsl/WVznbfYFrwzEOHQuMG0nUc+/i2K6qSFHLRUVsN\ntTR9KaXS+u9gBVWkplKeSC/ARDkKmg9vfeQrQD9dArX2zjI4D6bjt92z2QCt\ng7q275jY8pZdRWXMlqDOOfjknSQaoSnhhv9vliwII81YYmyTp+C62lZKKUmk\ncLK4UESsi0Qi41OnIjokQ2BRtCLL7HNGXuf3BlHbg6Vy2wsV9+QYsjHNsvy2\n2gsILoBxYFRB88cGDACgO0EoOJtHsVzYyxhMsDwc39I+B8QNvaM08QDMjiht\nsJDJsJ0+faaVZyKCT0s8eo9LwlePpR2yJq6k24mrecRzYdEo8iiYkmWCVp0s\nP4/Hc/hswQrtxqHxNBniy34RhclOCMoRZ2n6YmOUYNf2BULmfAiW1ea9x0Bd\npNMSOa6aM2xGNfYKSPQtLqiszbaQnNTectQyaCxqKR8Q8163drcSA3xi4MKN\nEjaF\r\n=jx7/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGcrm0u30wkM4b3Zm8D+kEJFedxkeXzQR+ijKUEU0qSwAiEA6WmEjnsWTy4kjmzyt90dVC8v8D8zJ+XwiF6urBlD4kE="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.1_1564567441408_0.44213049159949125"},"_hasShrinkwrap":false},"1.2.2":{"name":"umi-request","version":"1.2.2","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"010a56a5a7ff391351d16ff94dff505713843303","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"dist":{"integrity":"sha512-exe8ZDuOF6GQGrz0PQgxU/iWNRoEduk3uLIE+LkaBqrcV1CRyDo20bGp9cLv5UBHNz0/bMK84C6CKJtKmZB15w==","shasum":"102e59005f84aee3a515fd9c62ab34ec6cec0889","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.2.tgz","fileCount":6,"unpackedSize":63516,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdR5TmCRA9TVsSAnZWagAAr94P+wVD78B+4pXErCo0xMpx\n8XvgAUNS6oZihINtc5vPdirHT3V9a5pQUDveFOZEEB10bBe0z5k79Lj6zguI\nIPMHfw5QRqmNoIxxOu+ijclznAOHvSZz7TZe0s/lIrRsoYdhILSepwgNmmKC\nzfEDkYpdCOZMmlgFRdYDdkDfPmQtjPZebw53iTtd+qFHKJmvRiaJvJ5r4jVY\nc17TLHl0HGpd090+R4nJqxVdruUVUMJwgURyjV98AI/A/l+feTvg99JC9YON\n+RKArTHurTChExpXpeWktkUYTuVNnL6rjPsGzOGiBZDn98brkQVVRQTnw+YN\nsb9i/WvMt21/CamKJNALkLGAl7mfcMQMOYg/6NK7TTWQ6wT+SuXV3uKGeH/L\n5zJVrso5Rjkdo2GZfrM3qaUVMeb0VOm3Yc1DLK5R5BeSVzPsOZVjCAyPBB0s\nqMgQrNMhH/9CZacCkLvzmFQJzSSBiuIxI7/XgDNlsvMVO3mWsY4WxjW1ePz9\ntku2o1deF0N4/br183dE3EnnXjHXSAgj9lyW538bdGtbdVABvRAQ1qoURj11\nei324aioN890bFSU4lK+g9trMQAAzR1g8bC0o6SUOvzcsaZILSCh4A6mvZNZ\nxVEIPUA3KStq1WWY8kETL6WLCgl7o09ra8LNrD62+6a5OAQ0d7IVYX749oCO\nB1ns\r\n=onXy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDAL1be9mp0K3VYueK/KB1RktCKatRxwJXgm3egGU5cYwIhAJ+SX9lAoeyGBMxFMpZvJ0fjA0h8n3z3Akpsxp8w0p6+"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.2_1564972261969_0.84214659223279"},"_hasShrinkwrap":false},"1.2.3-beta.1":{"name":"umi-request","version":"1.2.3-beta.1","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n| parseResponse | response processing simplification | boolean | -- | true |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n| type | request type，type 'normal' would use fetch | string | -- | normal | \n\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"79551d9fc4e53d2b001c72c6d9f29e6828ae2512","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.3-beta.1","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-OOnWYZwEWdizJh7kwSISMGFJ3+4RBFf+kIVWPk/shyIShXynVcek/j5c9ftrSFfPmLzLS7uFzVHNluVFQ0HB0g==","shasum":"5ce9630ffdb126905820ec0da7ff6877214fccfb","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.3-beta.1.tgz","fileCount":6,"unpackedSize":70937,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVhSNCRA9TVsSAnZWagAAIhsQAI+cpF7p8lRMo+fx8QbB\nub37+MOgTc1fS/VKhu6Rq4XQ79UP6U4DsipazuVLq6Pk9eTQHF8kyb6rtN4B\nsZi7WbLsxBEiDikLQOVDWrJ+0u4qmtS1GkHXoMClBMRPYGZJlcJ/0rVBJDYu\nocHqJuN2UrKPa7qGBPLDD4yDaLZCiqsSe3RptcG9xJRSqORCLfHJV8GXG+4B\nGtSMZDPcfD5Zz2R/5kx341onq9iDSOqPtv+l21U2Amw8m2pY0qJ0Un/dEEam\n/ObQm2tKbBuYI06xOxbkWaH7QF5G9tWMZockNc+zFit2vxHZVZxdWu9wlvY9\nPPzCdejQOfpilcOj2LTsx+ygCPyzPh6bMWV868ts8UqXG4WAepAHP76v9nWu\nijy0S5UqTLcYIGnEomE1ja/s+czKf30weBK9L/RgYFwlnd4SBdVxPC8cyS/M\nVjmduU14Fj/wexGmDyGsxtB+tggizj29QARk8KkSrdGp2A5jGDatFqItHFdv\nX8sviUhOLFenmtliZuQdoxkdyKFi/GdGcZPjMRn4mJlNP9WwdmiNfPXORCGX\nObGnAan/8dIyj1NtdWhcEsZ168AI8/LLo6TmRm6FCtz2tDfRra4ibr3yfxR1\ndC69Mf9XF6Ea9xm0uCbuenpWHkH4h+7AsoEJpmXSIHydZrPSkAZBUCeNz2Xb\nuknh\r\n=z2Zn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDJ03cxKDVFdwTy1RJk/g7I7pJ0gzUEurKB+6ihB6A+GQIhAMhxKYGwSVicKeU4IX+Mzgf6k5RgB3PMJ6IV7x+0YO64"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.3-beta.1_1565922444993_0.17508460899658163"},"_hasShrinkwrap":false},"1.2.3":{"name":"umi-request","version":"1.2.3","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"query-string":"^6.0.0","whatwg-fetch":"^2.0.0"},"types":"types/index.d.ts","gitHead":"9ac67504c31d706acacb8562ea66489efde7fc0d","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.3","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-2XCUQP+Ix5a8/hgPlhst12LyOrLVA4chrQC/4LsJS3tp/FX/LV6bYM4clrfzGChZiOx+z7dqsAjfLxHCuKdPdQ==","shasum":"04e54891ad3e4d5a6ea3a5621a161e2127b3ebe6","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.3.tgz","fileCount":6,"unpackedSize":71013,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdXgYuCRA9TVsSAnZWagAA+oUP/iG4Ua0TxpBccc1N5Zm6\nJti5WWCmAWSd1Pb6hGnBb7LsXl3I4QemMtCOkpjIM420FTD7RW3SM4D9CczK\nt8Q1F8KCWhYjqK04OsTVag8C4BB1iFVXKmH10bCDCqUho1aM8VaIMgdPy7L1\nupJX6I/EOqzEZKNL0mN9Js1f4mYlflX7dzKr9JvpCAHSbEvuQUv+QpPvPouJ\nnHIuyj2SV3JPHRoT7iH/ma9/Gep22JeFK3zTuUEbDfzauiPr0M2ni5bJVT+x\nMlE/zPaAuPoP2V280atKXtJGftt8tblZ9cZ9QwIoKusZierlHL4qul5oP3ty\nvvzbDMcvCY8z607eT0UWdd+W6nwuvoI8intwwcXumcweAdmywpDD4PEsM3mR\nxbFUivdCCNugIdof45fAcSv684gDDuyurx7ZQLF4Ya8RV+I+MFptbHmL4DeI\njHMDgyxmZ7H4+6tE8tqqjRSDWxejQESevgsiK8nRszyAU1FCHf71ZsLnLCA1\nSXknkgvS5lV3N4GsbxSU9s6050xHTGTfYY9iVOa2wB1ssJBG1+nRkcs3LFhT\n/QY5SIs1+LxbQXahLwmUIejMaPAQx8Ljvra7nJOUr1LLQaQkAbd0B4Tn4Huu\nGsfsR5PKxMYeLHtG915aWcQ4HYHYmVbEeJEWYz40aUxeGv7chcyvfmtzZlsq\nKHfP\r\n=9QjZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqGVIJknC4gDiV207XerHqOK951BBMpd6OD4QmN0KrlAIgbqEg4iHkbl80C2FCni1rPPlXkBaS9IX3YIxYbraats4="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.3_1566443053795_0.021312343582343907"},"_hasShrinkwrap":false},"1.2.4-beta.0":{"name":"umi-request","version":"1.2.4-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"es6-promise":"^4.2.8","isomorphic-fetch":"^2.2.1","node-fetch":"^2.6.0","query-string":"^6.0.0","whatwg-fetch":"^3.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n| parseResponse | response processing simplification | boolean | -- | true |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n| type | request type，type 'normal' would use fetch | string | -- | normal | \n\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"da173448527d19a72e0881f8c502fa7fe4dd3753","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.4-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-kQP59DXKj6e+HNIOg5XNV6yuozu2WCZMZq5tv2NidbufRgnAECZPVkKp3GYhtOP7VerAURmDGpqSqZuI4SmJsw==","shasum":"214a30589c3fe2b34115bfec04c1dce48f6fffe5","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.4-beta.0.tgz","fileCount":6,"unpackedSize":71073,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdXgxqCRA9TVsSAnZWagAA33YP/3qGlexp0NWHjUC/p5Ma\nXWmwQQQZsBjVLFtviZaSiT1wjYKAxBxRxEQzD0Y/TFzI3KACMW1i4A2+vxMn\nWL2GRb20T/sp52J5XGPBNxJn2wyAxDy9vIE2u0bSteIGVXLlloyEfTU2SBrD\nyglmX1XNjIlGFi1xpfN+GI0onvMxXYounrqRbfbxugF3uY9PBucXkYi2LBl1\nOjxMGkYIGvx6dEaIxMcbM9z6/MgVGS48Ex0qOgMmPTxeggsWS90OwbNyBhHz\nPbzG6RDFmd7aHnCj8nxhHYV0O4hMstAawiddmjc+mdtAR6nqeBpnkSGjshCk\n91YsBeEq5vpGJ2MHjTdm/Xrnu+f1AqbNOqRFvht7Gu7CSFmMGehk26GvhKyd\nz3Lq1xcqdTL9KVvi84WrkQ3zsYy/YQrsFUhJmQTxUGPtTjvyNnuqGsF5oEw8\nNZxytCCIb+jnsDlr6Ke4COSiYbAnO22kasmfPOsJx61BGiKIxpfgbnAuIuIL\nABlYhgoAwSujvKFF+rOX+hVEjs95XxtZNY0RH6u4IYUb4dTYb+6zXktQkWn+\n7rtGlC7o+88lqBO/QK4xVTGPcxYjfUWeMW8La+Cn1kG2F7zdir4YH0mwBDsU\nhj+fw+fWmvS7aYCJ0ezKJf8PdBQAl9qzpApThEW3zIshAAR0FY+QMnYM1GUJ\nrmS7\r\n=onmJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCh30L8iArKp/RAEUVS7uz51iRuGY8jq1+yNWyQD11+yQIgD8DuVjeQkugrrLHlyXBSJMQeRJT7VtgkVNE0bSjY05I="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.4-beta.0_1566444649450_0.48781067861860516"},"_hasShrinkwrap":false},"1.2.4-beta.1":{"name":"umi-request","version":"1.2.4-beta.1","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"es6-promise":"^4.2.8","isomorphic-fetch":"^2.2.1","node-fetch":"^2.6.0","query-string":"^6.0.0","whatwg-fetch":"^3.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching (only support browser environment) | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n| parseResponse | response processing simplification | boolean | -- | true |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n| type | request type，type 'normal' would use fetch | string | -- | normal | \n\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## node request\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 })\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\n\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"120ba89532f2231cc57b2104993070874aa3152f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.4-beta.1","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-orgs0Y/oLgjPhqG6bFM0VtCjg0/sqSPI0cOFlkYfX7ynVOHW4AigiQQ3apVIbutm/cy8FukKLZOtWersISwjuQ==","shasum":"a508dc92c7333892c624ad364f967e5a4ba37b4b","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.4-beta.1.tgz","fileCount":6,"unpackedSize":73097,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdY1BZCRA9TVsSAnZWagAA15wP/jxHsTg69PopHEojG6Wj\np4ZHZlqWAIAa6GBs1LVtSGNrjm2JpicBS4hJ3x1Ansuj7WWfebavB0WSnXij\nyHqTGTKyJgVth/YYYTnBKeOIiML8sh/ye997u7TylTi8Z+wKS6rpHKanqJeG\nB4amrffP3Qcfo7JDdr63Rm3GsvoMRnDryt+nMNYgxerumNvlgjV+8qhQXo7Q\nJnUgEVpVtB/HTrT2IpsZ1lBVTeiMseaF8YuBQQsYRekQGuxEif9N3edd4UiJ\nxzPHC+qWtC6Dv2xMDcmxPNrkJWTfvz/d/zz+rvFWVJVP83VmNXTQAWqdZOvg\nwvlit/h2LcRK0RPxJ473ilYTUOYQA8HXGbunlLfcAkNSdbaYt5fP3Lxr2UzR\nXy0iHDRijjpQRpdVth5rDT0wKXMpl5ZTkjIgTv3ZFIygf+wkaDu8NnsXITbx\n7oEQ/piQQFY92dkmqIZgfWMPfOvrKiZ0JldUJprL/6/g/Gq3eaBZmcYItwgF\nYAgYkwkeDUXBWDyZIvv8FR0dGj54f1HWBaF9YIJc9F1sVJPmyAhgt7GdvoUh\nPgnybsgD48UAm3IlMMv14GcUPLoYBxo2G6a9rv6NqQVM33Jsuemmp4TbbLiT\n4mejI2j8DkBFeBcPWu3wgtoN/rUZ2cK+BaDSZUFYcrz9htEnXtxA3Zu4fWSE\ngm7X\r\n=aE+4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGyL3n/WhrefkKOu1I3UWyr4AEQ/1PlmR/EltDB49UkeAiEArCXs4dTe8Z8s/T/rgsd7Hox9KSUBNqgPETVrqMsdjwY="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.4-beta.1_1566789720669_0.5842242535991877"},"_hasShrinkwrap":false},"1.2.4":{"name":"umi-request","version":"1.2.4","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"827b7d73e71f48af61663a96fe18d3b137e071a8","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.4","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-OjyqRYIotM/QIVisL5I0EOqIEowqF8aQ05stAZ60DFLsHqiZk3FG1WoofX+5Y8cwjf4aeyByNo8Mwr1kBxjzbg==","shasum":"c88e549c4f96096a2a74a6cdc2910564761bc06f","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.4.tgz","fileCount":6,"unpackedSize":72961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZ3YGCRA9TVsSAnZWagAA5I8QAIInU/tVWxxZTfF/YUiF\n6wSiRF5y7KQKUhAyyYcqVviUaPqbAlVUo4dxG7JOzbxqIxeQNAeKGH6gDxbu\nePp4o1/eSSfUvrG7YAUbYItOe1ciLqvanSfPISb8ttW3pWn2hG12oSXl5VxC\n79/LCW7k5hyI0VLKu2UQcN8lvgwWXcIMhG2CVacVyxFsSen3U/iQsFDcmJ5a\n5NdFo2/1VoVT0WBi9A8kLSWWLATEDy5MwFOX1ZXhRNhkr7x63fQWuF76ma6h\n2mUjE7v3YUnZ1HKOympa6PVCxhfseMM62/8vOFXJwp+uMf5CBKkULHt8NVYE\nmxFp9OPiE6aOXxvcanM/bgVXpNW3OMlBbTWQeChKW/4wflElBAg7of/fRBbD\nBpppQmW3Ntmq+kDax8KKiLe5AogeazCy5iI3V59H9KTcGetlU4+xpXU8u0Sa\nvwNFBX7sFXiworzMrjLa1OVTdQMIN4c8BUfHx5t5kGI6n1DEy5S71kmjmK4e\n5TBgyTC1KnBrYEyj5H8JaMmORLTkVPrZk2EiMVjYwdKenkoUSqOm1orGMsgX\nUKLgk/Hks7j5mlT0dZbf2HYF1dglgYQcx4v15W0TrfVp52GTYtNjvPPB5hk0\nkBKU+h/sPSbM4IzVwoEvCcQ3Yo5y6jrvVfB9tMw0qHarCs5bVq0O5+DjNqzP\nksBX\r\n=2Ng+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEl+GyY5xGIlyrOkWdPHWdL2R/eEeAmCWwfySIjTJw5FAiEA7HoiNicbPG0axtuRzYfiV82OjMT0vbTCyELCpVOb1ls="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.4_1567061509621_0.28858588372674965"},"_hasShrinkwrap":false},"1.2.5-beta.0":{"name":"umi-request","version":"1.2.5-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [ ] rpc support\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n`npm install umi-request --save`\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| charset | character set | string | utf8 , gbk | utf8 |\n| requestType | post request data type | string | json , form | json |\n| data | Submitted data | any | -- | -- |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| useCache | Whether to use caching (only support browser environment) | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| headers | fetch original parameters | object | -- | {} |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n| parseResponse | response processing simplification | boolean | -- | true |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Default |\n| :--- | :--- | :--- | :--- |\n| maxCache | Maximum number of caches | number | Any |\n| prefix | default url prefix | string | -- |\n| errorHandler | default exception handling | function(error) | -- |\n| headers | default headers | object | {} |\n| params | default with the query parameter | object | {} |\n| ... |\n\n## Use\n\n> request can be used in a simple package and can be used with reference to [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n```javascript\n// request is the default instance that can be used directly, extend is a configurable method, passing a series of default parameters, returning a new request instance, usage is consistent with the request.\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  maxCache: 10, // The maximum number of caches. When it is exceeded, it will automatically clear the first one according to the time.\n  prefix: '/api/v1', // prefix\n  suffix: '.json', // suffix\n  errorHandler: (error) => {\n    // Centralized processing error\n  },\n  headers: {\n    Some: 'header' // unified headers\n  },\n  params: {\n    Hello: 'world' // the query parameter to be included with each request\n  }\n});\nrequest('/some/api');\n\n// Support syntax sugar such as: request.get request.post ...\nrequest.post('/api/v1/some/api', { data: {foo: 'bar'}});\n\n// request an api, no method parameter defaults to get\nrequest('/api/v1/some/api').then(res => {\n  console.log(res);\n}).catch(err => {\n  console.log(err);\n});\n\n// url parameter serialization\nrequest('/api/v1/some/api', { params: {foo: 'bar'} });\n\n// post data submission simplification\n// When data is object, the default requestType: 'json' can not write, header will automatically bring application / json\nrequest('/api/v1/some/api', { method:'post', data: {foo: 'bar'} });\n\n// requestType: 'form', header will automatically bring application/x-www-form-urlencoded\nrequest('/api/v1/some/api', { method:'post', requestType: 'form', data: {foo: 'bar'} });\n\n// reponseType: 'blob', how to handle the returned data, by default text and json are not added. Such as blob or formData need to add\nrequest('/api/v1/some/api', { reponseType: 'blob' });\n\n// Submit other data, such as text, requestType is not filled, manually add the corresponding header.\nrequest('/api/v1/some/api', { method:'post', data: 'some data', headers: { 'Content-Type': 'multipart/form-data'} });\n\n// upload file\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', body: formData, requestType: 'form' });\n\n// The default is to return the data body, if you need the source response to expand, you can use the getResponse parameter. The result will be a set of layers\nrequest('/api/v1/some/api', { getResponse: true }).then({data, response} => {\n  console.log(data, response);\n});\n\n// Timeout in milliseconds, but after the timeout, although the client returns a timeout, but the api request will not be disconnected, the write operation is used with caution.\nrequest('/api/v1/some/api', { timeout: 3000 });\n\n// Use the cache, only valid when get. Units of milliseconds, do not add ttl default 60s, ttl = 0 does not expire. cache key for url + params combination\nrequest('/api/v1/some/api', { params: { hello: 'world' }, useCache: true, ttl: 10000 });\n\n// This parameter can be used when the server returns gbk to avoid garbled characters.\nrequest('/api/v1/some/api', { charset: 'gbk' });\n\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, handling response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n\n// use middleware, handling request and response\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  // add prefix\n  ctx.req.url = `/api/v1/${url}`;\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // Handle fail request here\n  }\n})\n\n```\n\n## node request\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 })\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\n\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n/**\n * Here are four ways to deal with\n */\n/**\n * 1. Unified processing\n * Commonly used in projects where the error code is more standardized, and the error is handled centrally.\n */\n\nconst codeMap = {\n  '021': 'An error has occurred',\n  '022': 'It’s a big mistake,'\n  ...\n};\n\nconst errorHandler = (error) => {\n  const { response, data } = error;\n  message.error(codeMap[data.errorCode]);\n\n  throw error; // If throw. The error will continue to be thrown.\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n}\n\nconst extendRequest = extend({\n  prefix: server.url,\n  errorHandler\n});\n\nconst response = await extendRequest('/some/api'); // will automatically handle the error, no catch. If throw needs to catch.\nif (response) {\n  // do something\n}\n\n/**\n* 2. Separate special treatment\n* If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\n*/\nconst response = await extendRequest('/some/api', {\n  method: 'get',\n  errorHandler: (error) => {\n    // do something\n  }\n});\n\n/**\n * 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\n */\ntry {\n  const response = await request('/some/api');\n} catch (error) {\n  // do something\n}\n\n/**\n* 4. Based on response interceptors\n*/\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: 'Gateway error. ',\n    503: 'The service is unavailable, the server is temporarily overloaded or maintained. ',\n    504: 'The gateway timed out. ',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n/**\n* 5. For the status code is actually 200 errors\n*/\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = 'login url';\n  }\n  return response;\n})\n```\n\n\n## Middleware\nrequest.use(fn)\n\n### params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\n### example\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"ed0bf89c031435db1c951eeb45595768a1440526","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.5-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-iKhWRHs3lRIYc2WGiiCTIajgJIRTVpQpaIOu1/88kLA1SgIxMI1swSVozniqaPcPj8bYjC8YS94EhQVbrto2jw==","shasum":"0fd20e6eb1f4ec7d4289c46ac59d9e49b0ff8b21","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.5-beta.0.tgz","fileCount":6,"unpackedSize":77909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdbg7ZCRA9TVsSAnZWagAA8/YP/02JpGLp7Ildr7AHd3NS\nBg0R6cyfFQGjs08UutbFTSadwXoq2OtvPbL93p1th7aWT/f+9Fyt2IfjCLxx\nRdydwhc0F0ZN4IAsU/uy795BCheVHGr62ZfhuE20aXs64PYbc/AOiLgQr7/l\nZ3Ya004bkDEvmkSFCNwGOUfsYUUNXo3Vqka/OxTbn6nDCcpVx5xsC4R63+vA\n3sPeVQRM7xXC8IxADayErjaCJ+jiLm/6++3eEEAE5uHtMeXYE1rGOGWb1qYW\nuw8HUFc4srd7JFnmUhqW+CCR/4uFZCvuparrfY+UYu1VXuJLemn7yWUqSCw6\n5bU54ue9kaoIaWv0+8fQTs1mJ0LB/3o7BZNj0ea7jMsoR9tK9WUPirNHbSf1\nHULslOf6sQGLOVDng/fbfToYY1HZyPWx/VdoGVzW7JDQ3A0SH5YMu8cH6vn0\n0CT5GFk6KHzpOA4K+kv3ahEYYFr+N6/Qn4p1kTY5L8XeCAQiIicTV6Kg6Lae\nte6whkAa3DlHf/+GBmN0eB1VtdTHOVSGP7Y0AzY4wTpzjMrouPJGel7fLHJ/\njm9jdZPeJI38BTFIjdcVZ5lqB75p9pxRmoax0qREm8UGq41TZ7uFJfk1jGMt\nyWp6TzI/B3i5yP+GugbNHEarAvLzj5XHDszn4rA0vKZFOzhYunMcNeFVHzfK\nRZwq\r\n=j6Eb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGXhM48yWXSj7cmqJSUGr4zJNgwa+Sz4CrCclZV1qtqQIhANNd+qY/BXK/fMrkMbrSRtwe6plU6QFunP03H35C2MtD"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.5-beta.0_1567493848543_0.46106593521805816"},"_hasShrinkwrap":false},"1.2.5":{"name":"umi-request","version":"1.2.5","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"d01dada313d9cd9f9a37024d2e9df3a04276fdc9","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.5","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-uerMytksqi/JrBhZFUGq/wygrHhztLAVkYOX9/Iu+RzJQTOEw9mKsrH1W0rmF1Id7oZYXpWU8V0G3oH9SqKupg==","shasum":"368e3b8d7d30d231f899c59d374b043d4219f17a","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.5.tgz","fileCount":6,"unpackedSize":77971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJddgpsCRA9TVsSAnZWagAAeHQQAJgQA0a7cNncjidH+9ra\nX4aQjcd774nvM14xU0E3qEV+G00ORmq+1+wEghIU/2ImOUZjXRUjW6rBueUs\nNyCeIArXLGyipuFLWA2JslVPmGvCXehL8WtpLMNx/hp1zyz9XSR7VlpYtyPR\nDqQZaa4iOqkH5rQOAve9f0yuvAGQcJ7WJhkQwi4MXnJZAOArGCIKgEXxWlJh\nYaIwelgT8ko+y7LXuJ7rLj9aAHElLKQvTLImj1OY83xpdvboconrkL8/Xhie\n4iFHslaznGdaFYXVwu/RIBH4xL0Ez7QgOS/th/BcrtNSyvf2RRA/ILLIAdTR\n41E+JkDZ1lLTO43oLGhcNvVzRIXz88svdyfW9ueDyuwqyGReXCfewK9sBbBd\nWP8HqhSDeW5LDhvVIcS5qiV81ExBYqbo/QoanDcAGlOX/SJZ8+RP0xfx1iU3\ntkbjRYrkBUIjtxqnsBLsj8V7F63qEVNE7d26J4E7o5DVXgTXvgJ+9fnPhh8a\nN17yx9zf0EZfSSSK8LJccabrrK15Fu8I+bz2ut0Xx82qX4As6SsiaX3OtP4e\nVNYg0185ueT55w0Lo8LYs7xbrCYmXFxZvAVuqAK/J7al3vXn+zfUdofn79s0\ntwLBS/ez0MyRHJ2lDjt1Pkt8ticRAqmQD0xQv/zlA7EZTUALwmI1ucBfj3uM\n3s11\r\n=yRnU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCe/XZexWxVyFAWNXvH2A9WU8SvHSdl+7wMqxR9rk1s6AIhANna8uqHzJTC1bp8ACDYnYejjFxedLq+p2JXYs4tz3cI"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.5_1568017004009_0.26534215759155066"},"_hasShrinkwrap":false},"1.2.6-beta.0":{"name":"umi-request","version":"1.2.6-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n```\nnpm install --save umi-request\n```\n\n## Example\nPerforming a ```GET``` request\n\n``` javascript\nimport request from 'umi-request';\n\nrequest.get('/api/v1/xxx?id=1')\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\n// use options.params\nrequest.get('/api/v1/xxx', {\n    params: {\n      id: 1\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\nPerforming a ```POST``` request\n``` javascript\nrequest.post('/api/v1/user', {\n    data: {\n      name: 'Mike'\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\n## umi-request API\nRequests can be made by passing relevant options to ```umi-request```\n\n**umi-request(url[, options])**\n```javascript\nimport request from 'umi-request';\n\nrequest('/api/v1/xxx', {\n    method: 'get',\n    params: { id: 1 }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\nrequest('/api/v1/user', {\n    method: 'post',\n    data: {\n      name: 'Mike'\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\n```\n\n## Request method aliases\nFor convenience umi-request have been provided for all supported methods.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\n\n## Creating an instance\nYou can use ```extend({[options]})``` to create a new instance of umi-request.\n\n**extend([options])**\n\n``` javascript\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  prefix: '/api/v1',\n  timeout: 1000,\n  headers: {\n    'Content-Type': 'multipart/form-data'\n  }\n});\n\nrequest.get('/user')\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\nCreate an instance of umi-request in NodeJS enviroment\n\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 })\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\nThe available instance methods are list below. The specified options will be merge with the instance options.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\nMore umi-request cases can see [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| data | Submitted data | any | -- | -- |\n| headers | fetch original parameters | object | -- | {} |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| credentials | fetch request with cookies | string | -- | credentials: 'include' |\n| useCache | Whether to use caching (only support browser environment) | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| maxCache | Maximum number of caches | number | -- | 0(Infinity) |\n| requestType | post request data type | string | json , form | json |\n| parseResponse | response processing simplification | boolean | -- | true |\n| charset | character set | string | utf8 , gbk | utf8 |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| data | Submitted data | any | -- | -- |\n| ... |\n\n\n``` javascript\n{\n  // 'method' is the request method to be used when making the request\n  method: 'get', // default\n\n  // 'params' are the URL parameters to be sent with request\n  params: { id: 1 },\n\n  // 'data' 作为请求主体被发送的数据\n  // 适用于这些请求方法 'PUT', 'POST', 和 'PATCH'\n  // 必须是以下类型之一：\n  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // - 浏览器专属：FormData, File, Blob\n  // - Node 专属： Stream\n\n  // 'data' is the data to be sent as the request body\n  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n  // Must be of one of the following types:\n  // 1. string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // 2. Browser only: FormData, File, Blob\n  // 3. Node only: Stream\n  data: { name: 'Mike' },\n\n  // 'headers' are custom headers to be sent\n  headers: { 'Content-Type': 'multipart/form-data' },\n\n  // 'timeout' specifies the number of milliseconds before the request times out.\n  // If the request takes longer than 'timeout', request will be aborted and throw RequestError.\n  timeout: 1000,\n\n  // ’prefix‘ used to set URL's prefix\n  // ( e.g. request('/user/save', { prefix: '/api/v1' }) => request('/api/v1/user/save') )\n  prefix: '',\n\n  // ’suffix‘ used to set URL's suffix\n  // ( e.g. request('/api/v1/user/save', { suffix: '.json'}) => request('/api/v1/user/save.json') )\n  suffix: '',\n\n  // 'credentials' indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n  // omit: Never send or receive cookies.\n  // same-origin: Send user credentials (cookies, basic http auth, etc..) if the URL is on the same origin as the calling script. This is the default value.\n  // include: Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls.\n  credentials: 'include',\n\n  // ’useCache‘ The GET request would be cache in ttl milliseconds when 'useCache' is true.\n  // The cache key would be 'url + params'.\n  useCache: false, // default\n\n  // 'ttl' cache duration（milliseconds），0 is infinity\n  ttl: 60000,\n\n  // 'maxCache' are the max number of requests to be cached, 0 means infinity.\n  maxCache: 0,\n\n  // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object or array.\n  // 1. requestType === 'json' :(default )\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/json;charset=UTF-8',\n  //   ...options.headers,\n  // }\n  // options.body = JSON.stringify(data)\n  // \n  // 2. requestType === 'form':\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',\n  //   ...options.headers,\n  // };\n  // options.body = query-string.stringify(data);\n  // \n  // 3. other requestType\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   ...options.headers,\n  // };\n  // options.body = data;\n  requestType: 'json', // default\n\n  // 'parseResponse' whether processing response \n  parseResponse: true, // default\n\n  // 'charset' This parameter can be used when the server returns gbk to avoid garbled characters.(parseResponse should set to true)\n  charset: 'gbk',\n\n  // 'responseType': how to processing response.(parseResponse should be true)\n  // The default value is 'json', would processing response by Response.text().then( d => JSON.parse(d) )\n  // Other responseType (text, blob, arrayBuffer, formData), would processing response by Response[responseType]()\n  responseType: 'json', // default\n\n  // 'throwErrIfParseFail': whether throw error or not when JSON parse data fail and responseType is 'json'.\n  throwErrIfParseFail: false, // default\n\n  // 'getResponse': if you need the origin Response, set true and will return { data, response }.\n  getResponse: false,// default\n\n  // 'errorHandler' error handle entry.\n  errorHandler: function(error) { /* 异常处理 */ },\n\n  // 'cancelToken' the token of cancel request.\n  cancelToken: null,\n}\n```\n\n\n\n## Response Schema\n\nThe response for a request contains the following information.\n``` javascript\n{\n  // 'data' is the response that was provided by the server\n  data: {},\n\n  // 'status' is the HTTP status code from the server response\n  status: 200,\n\n  // 'statusText' is the HTTP status message from the server response\n  statusText: 'OK',\n\n  // 'headers' the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n}\n```\n\nWhen options.getResponse === false, the response schema would be 'data'\n\n``` javascript\nrequest.get('/api/v1/xxx', { getResponse: false })\n  .then(function(data) {\n    console.log(data);\n  })\n```\n\nWhen options.getResponse === true ，the response schema would be { data, response }\n\n``` javascript\nrequest.get('/api/v1/xxx', { getResponse: true })\n  .then(function({ data, response }) {\n    console.log(data);\n    console.log(response.status);\n    console.log(response.statusText);\n    console.log(response.headers);\n  })\n\n```\n\nYou can get Response from ```error``` object in errorHandler or request.catch.\n\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n\nconst errorHandler = function (error) {\n  const codeMap = {\n    '021': 'An error has occurred'',\n    '022': 'It’s a big mistake,',\n    // ....\n  };\n  if (error.response) {\n    // The request was made and the server responded with a status code\n    // that falls out of the range of 2xx\n    console.log(error.response.status);\n    console.log(error.response.headers);\n    console.log(error.data);\n    console.log(error.request);\n    console.log(codeMap[error.data.status])\n    \n  } else {\n    // The request was made but no response was received or error occurs when setting up the request.\n    console.log(error.message);\n  }\n\n  throw error; // If throw. The error will continue to be thrown.\n  \n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n  // return {some: 'data'}; \n}\n\n// 1. Unified processing\nconst extendRequest = extend({ errorHandler });\n\n// 2. Separate special treatment\n// If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\nrequest('/api/v1/xxx', { errorHandler });\n\n\n// 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\nrequest('/api/v1/xxx')\n.then(function (response) {\n  console.log(response);\n})\n.catch(function (error) {\n  return errorHandler(error);\n})\n```\n\n\n## Middleware\nExpressive HTTP middleware framework for node.js. For development to enhance before and after request. Support create instance, global, core middlewares.\n\n**Instance Middleware (default)** request.use(fn) Different instances's instance middleware are independence.\n**Global Middleware** request.use(fn, { global: true }) Different instances share global middlewares.\n**Core Middleware** request.use(fn, { core: true }) Used to expand request core.\n\nrequest.use(fn[, options])\n\n### params\nfn params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\noptions params\n* global(boolean): whether global， higher priority than core\n* core(boolean): whether core\n\n\n### example\n1. same type of middlewares\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n\n2. Defferent type of middlewares\n``` javascript\nrequest.use( async (ctx, next) => {\n  console.log('instanceA1');\n  await next();\n  console.log('instanceA2');\n})\nrequest.use( async (ctx, next) => {\n  console.log('instanceB1');\n  await next();\n  console.log('instanceB2');\n})\nrequest.use( async (ctx, next) => {\n  console.log('globalA1');\n  await next();\n  console.log('globalA2');\n}, { global: true })\nrequest.use( async (ctx, next) => {\n  console.log('coreA1');\n  await next();\n  console.log('coreA2');\n}, { core: true })\n```\n\norder of middlewares be called:\n```\ninstanceA1 -> instanceB1 -> globalA1 -> coreA1 -> coreA2 -> globalA2 -> instanceB2 -> instanceA2\n```\n\n3. Enhance request\n``` javascript\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n\n  if ( url.indexOf('/api') !== 0 ) {\n    ctx.req.url = `/api/v1/${url}`;\n  }\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res; \n  if (!success) {\n    // ...\n  }\n})\n\n```\n\n4. Use core middleware to expand request core.\n``` javascript\n\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  const { __umiRequestCoreType__ = 'normal' } = options;\n  \n  // __umiRequestCoreType__ use to identificat request core\n  // when value is 'normal' , use umi-request 's fetch request core\n  if ( __umiRequestCoreType__ === 'normal') {\n    await next();\n    return;\n  }\n\n  // when value is not normal, use your request func. \n  const response = getResponseByOtherWay();\n\n  ctx.res = response;\n\n  await next();\n  return;\n}, { core: true });\n\n\nrequest('/api/v1/rpc', {\n  __umiRequestCoreType__: 'rpc',\n  parseResponse: false,\n})\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  })\n\n```\n\n\n## Interceptor\nYou can intercept requests or responses before they are handled by then or catch.\n\n``` javascript\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, chagne response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n// handling error in response interceptor\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n// clone response in response interceptor\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = '登录url';\n  }\n  return response;\n})\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## FAQ\n### How to get Response Headers\nuse **Headers.get()** to get information from Response Headers. ( more detail see [MDN doc](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n\n``` javascript\nrequest('/api/v1/some/api', { getResponse: true })\n.then(({ data, response}) => {\n  response.headers.get('Content-Type');\n})\n```\n\nIf want to get a custem header, you need to set [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) on server.\n\n\n\n## Cases\n### How to get Response Headers\n\nUse **Headers.get()** (more detail see [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n``` javascript\nrequest('/api/v1/some/api', { getResponse: true })\n.then(({ data, response}) => {\n  response.headers.get('Content-Type');\n})\n```\n\n### File upload\nUse FormData() contructor，the browser will add rerequest header  ```\"Content-Type: multipart/form-data\"``` automatically, developer don't need to add request header **Content-Type**\n``` javascript\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', data: formData });\n```\n\n\nThe Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.[Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)\n\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"6ba1f4c8e8bbadca396fc2c616a75b44b5e4f967","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.6-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-9xGpzkGOr05+YVzq21XB/xy7n2NlZuHFQzgvYgTBa2uOFxXawd527fCDTMGjXbU/856YNpZWKOS6KTCexTFdow==","shasum":"bcd6d29d7706cc9cdad5a8d807243d342530cd2d","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.6-beta.0.tgz","fileCount":6,"unpackedSize":86954,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdiHR2CRA9TVsSAnZWagAAH9IP/jscWru3dOk0phKB4VKk\nyr0gT+Kt9VJCYcuIh9iytK7al6WSBtQWaXBtqvu0o5S7t8Sob3BHax85VtZC\n9TVnGaM3YCxGFt39HD8KG5nMHVwxOUlD0R9W65Hd6ubaSIhr4IGXENv2gQtl\nvpoPjpodux2injql92R4Y44Dx1WGASDKDHgR0/7vBvUU7EzrBWQUh17GSCO/\nqMfun3sxpSMctN22r4nYmB3pQEY1V2BpAvdAD6+Ko2Ngl388wMYCSGw7HnSD\nwbG67Rogx1t0bIoikigh5rONwjWWvi4SejwNo9Zm2wfNggTmCInoN2aE18Oz\nxZlIharUS1E+ZHL/Oz+RPeyWeB6k+4eCE3hae6VpzOqt1R45RnLj79sKTB+5\nSaPBvR5A4qRLNz+1kYCpRpR82YCHhQxZASld2CRstYueEs+0TdfAXYmYJrHY\n/rFiszTSwtO7YrBwl4son/VifKazxz/maZTRYjY9wsItM39XXRejaUO6lSpM\nfBSrWNEmhB8u19Rem3s8D877ovclAXNO/sAZkbUZ0sLc1+3e+b/Dfro8snn1\nfKbU2lulSzHl1+S/0rg1bXAfrX9DNp13CjwsCsEBb90/JnjOPoUivYy3aopx\nHYWAeCEjkb/VrjBQ9RwZ8Gwu1UKG0oPvdfcnLxjAB10TJa2O+r+IFcE2ljqb\nAKHY\r\n=3bRP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBtIlQoSKlNs63u4mlDFfE7ZfY/KXJGVl9hPV46ZSm7aAiAwn/emli1e71+6+w1ietZUOa2c4SRth8Wvb8gBQBFDGg=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.6-beta.0_1569223797742_0.7777145483083467"},"_hasShrinkwrap":false},"1.2.6":{"name":"umi-request","version":"1.2.6","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"3ef4c7361b3bb6d17bdb52713175b93f99e02958","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.6","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-aGQFKIgkIZTjobWinnKYQm4peoO08zMuh5Qnsopo+QgqosYVEDZDYupyw67gqbpjpz13nwYT6UrTNAdgLJ7sGQ==","shasum":"bf92faeaf127f7bb10b44f639d61a016cf2e8d9d","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.6.tgz","fileCount":6,"unpackedSize":86986,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdiIQ5CRA9TVsSAnZWagAAIEYP/0tz17xO8gCs0QhWT8L+\nyQVUbZ3JNfSZCiXztf0VRRogNAnJkrsffgH38alOffKOInpvJIchZ9O0zODF\nykQwh9ux12gzqqM1NiKOTD2i9bKkrzpBXz1Qx307hjdX+mbMvp2se8zf8rHW\nn2dzamM/8Cskf6IZmd0frlAST+Z4roa1A/vpchGBQu2o+uI6Bc3JmsEZSfRR\nD1UexgcdzyT56NfeYdAIZmdggzEX7BEOb96UnXUoPYJrf79/nHGUOXGDp7oX\nzroh6e56OFBSEeDAe0pAO1GX0TxsvDK/tIfWqFg9Os+OZ4T+Gq1e8tAntpdk\nkWDVHzIUvLyyRtGvnhUS0iFKG+AdASJl1cMRfxvZChXirWMIPSpU2Fj6FSW9\nnZuGxFQSJhHBd81IBiP3zkJMRUUgfMmk8wUwLGc+Yt6h3cEcrlZTFXO7pt/t\naGwv7HWcYcfHxw+3VRP1aYZCSuWh/P2REJQ7WL4SYjORAxNyzs0uPVHGprkB\nnGikDpxmn/Xt3PvKV6RUX7rs/3ACCJLxO5nSr9G19/oKXr6A7sQFC+hVNwZD\nes83coDfLNEnpi66Fe9kKv9iFlgIH2+IcgUMTm6KOE5LEn1LA3Zn0s0fxDiJ\nRvcOE4D18Q7kE9l/gy6tED7K40RH7cIdkNc0em2QnzMPJkJP8LIGfMgZEO5e\nNeL1\r\n=nk56\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIANzzlF/G15xwQNpIHUnsolWOm7tB38y78vk6L9Z9arRAiA2XZqKipv6KH0QJ5HMjcMR3OLQMK0WDwMLP9DSKC7rRg=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.6_1569227832264_0.9117148184016408"},"_hasShrinkwrap":false},"1.2.7-beta.0":{"name":"umi-request","version":"1.2.7-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n--------------------\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features | umi-request | fetch | axios |\n| :---------- | :-------------- | :-------------- | :-------------- |\n| implementation | Browser native support | Browser native support | XMLHttpRequest |\n| size | 9k | 4k (polyfill) | 14k |\n| query simplification | ✅ | ❎ | ✅ |\n| post simplification | ✅ | ❎ | ❎ |\n| timeout | ✅ | ❎ | ✅ |\n| cache | ✅ | ❎ | ❎ |\n| error Check | ✅ | ❎ | ❎ |\n| error Handling | ✅ | ❎ | ✅ |\n| interceptor | ✅ | ❎ | ✅ |\n| prefix | ✅ | ❎ | ❎ |\n| suffix | ✅ | ❎ | ❎ |\n| processing gbk | ✅ | ❎ | ❎ |\n| middleware | ✅ | ❎ | ❎ |\n| cancel request | ✅ | ❎ | ✅ |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n```\nnpm install --save umi-request\n```\n\n## Example\nPerforming a ```GET``` request\n\n``` javascript\nimport request from 'umi-request';\n\nrequest.get('/api/v1/xxx?id=1')\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\n// use options.params\nrequest.get('/api/v1/xxx', {\n    params: {\n      id: 1\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\nPerforming a ```POST``` request\n``` javascript\nrequest.post('/api/v1/user', {\n    data: {\n      name: 'Mike'\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\n## umi-request API\nRequests can be made by passing relevant options to ```umi-request```\n\n**umi-request(url[, options])**\n```javascript\nimport request from 'umi-request';\n\nrequest('/api/v1/xxx', {\n    method: 'get',\n    params: { id: 1 }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\nrequest('/api/v1/user', {\n    method: 'post',\n    data: {\n      name: 'Mike'\n    }\n  })\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n\n```\n\n## Request method aliases\nFor convenience umi-request have been provided for all supported methods.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\n\n## Creating an instance\nYou can use ```extend({[options]})``` to create a new instance of umi-request.\n\n**extend([options])**\n\n``` javascript\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  prefix: '/api/v1',\n  timeout: 1000,\n  headers: {\n    'Content-Type': 'multipart/form-data'\n  }\n});\n\nrequest.get('/user')\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\nCreate an instance of umi-request in NodeJS enviroment\n\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 })\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\nThe available instance methods are list below. The specified options will be merge with the instance options.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\nMore umi-request cases can see [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n\n## request options\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object or URLSearchParams | -- | -- |\n| data | Submitted data | any | -- | -- |\n| headers | fetch original parameters | object | -- | {} |\n| timeout | timeout, default millisecond, write with caution | number | -- | -- |\n| prefix | prefix, generally used to override the uniform settings prefix | string | -- | -- |\n| suffix | suffix, such as some scenes api need to be unified .json | string | -- |\n| credentials | fetch request with cookies | string | -- | credentials: 'same-origin' |\n| useCache | Whether to use caching (only support browser environment) | boolean | -- | false |\n| ttl | Cache duration, 0 is not expired | number | -- | 60000 |\n| maxCache | Maximum number of caches | number | -- | 0(Infinity) |\n| requestType | post request data type | string | json , form | json |\n| parseResponse | response processing simplification | boolean | -- | true |\n| charset | character set | string | utf8 , gbk | utf8 |\n| responseType | How to parse the returned data | string | json , text , blob , formData ... | json , text |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json' | boolean | -- | false |\n| getResponse | Whether to get the source response, the result will wrap a layer | boolean | -- | fasle |\n| errorHandler | exception handling, or override unified exception handling | function(error) | -- |\n| cancelToken | Token to cancel request | CancelToken.token | -- | -- |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description | Type | Optional Value | Default |\n| :--- | :--- | :--- | :--- | :--- |\n| method | request method | string | get , post , put ... | get |\n| params | url request parameters | object | -- | -- |\n| data | Submitted data | any | -- | -- |\n| ... |\n\n\n``` javascript\n{\n  // 'method' is the request method to be used when making the request\n  method: 'get', // default\n\n  // 'params' are the URL parameters to be sent with request\n  // Must be a plain object or a URLSearchParams object\n  params: { id: 1 },\n\n  // 'paramSerializer' is a function in charge of serializing 'params'. ( be aware of 'params' was merged by extends's 'params' and request's 'params' and URLSearchParams will be transform to plain object. )\n  paramsSerializer: function (params) {\n    return Qs.stringify(params, { arrayFormat: 'brackets' })\n  },\n\n  // 'data' 作为请求主体被发送的数据\n  // 适用于这些请求方法 'PUT', 'POST', 和 'PATCH'\n  // 必须是以下类型之一：\n  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // - 浏览器专属：FormData, File, Blob\n  // - Node 专属： Stream\n\n  // 'data' is the data to be sent as the request body\n  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n  // Must be of one of the following types:\n  // 1. string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // 2. Browser only: FormData, File, Blob\n  // 3. Node only: Stream\n  data: { name: 'Mike' },\n\n  // 'headers' are custom headers to be sent\n  headers: { 'Content-Type': 'multipart/form-data' },\n\n  // 'timeout' specifies the number of milliseconds before the request times out.\n  // If the request takes longer than 'timeout', request will be aborted and throw RequestError.\n  timeout: 1000,\n\n  // ’prefix‘ used to set URL's prefix\n  // ( e.g. request('/user/save', { prefix: '/api/v1' }) => request('/api/v1/user/save') )\n  prefix: '',\n\n  // ’suffix‘ used to set URL's suffix\n  // ( e.g. request('/api/v1/user/save', { suffix: '.json'}) => request('/api/v1/user/save.json') )\n  suffix: '',\n\n  // 'credentials' indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n  // omit: Never send or receive cookies.\n  // same-origin: Send user credentials (cookies, basic http auth, etc..) if the URL is on the same origin as the calling script. This is the default value.\n  // include: Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls.\n  credentials: 'same-origin', // default\n\n  // ’useCache‘ The GET request would be cache in ttl milliseconds when 'useCache' is true.\n  // The cache key would be 'url + params'.\n  useCache: false, // default\n\n  // 'ttl' cache duration（milliseconds），0 is infinity\n  ttl: 60000,\n\n  // 'maxCache' are the max number of requests to be cached, 0 means infinity.\n  maxCache: 0,\n\n  // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object or array.\n  // 1. requestType === 'json' :(default )\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/json;charset=UTF-8',\n  //   ...options.headers,\n  // }\n  // options.body = JSON.stringify(data)\n  // \n  // 2. requestType === 'form':\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',\n  //   ...options.headers,\n  // };\n  // options.body = query-string.stringify(data);\n  // \n  // 3. other requestType\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   ...options.headers,\n  // };\n  // options.body = data;\n  requestType: 'json', // default\n\n  // 'parseResponse' whether processing response \n  parseResponse: true, // default\n\n  // 'charset' This parameter can be used when the server returns gbk to avoid garbled characters.(parseResponse should set to true)\n  charset: 'gbk',\n\n  // 'responseType': how to processing response.(parseResponse should be true)\n  // The default value is 'json', would processing response by Response.text().then( d => JSON.parse(d) )\n  // Other responseType (text, blob, arrayBuffer, formData), would processing response by Response[responseType]()\n  responseType: 'json', // default\n\n  // 'throwErrIfParseFail': whether throw error or not when JSON parse data fail and responseType is 'json'.\n  throwErrIfParseFail: false, // default\n\n  // 'getResponse': if you need the origin Response, set true and will return { data, response }.\n  getResponse: false,// default\n\n  // 'errorHandler' error handle entry.\n  errorHandler: function(error) { /* 异常处理 */ },\n\n  // 'cancelToken' the token of cancel request.\n  cancelToken: null,\n}\n```\n\n\n\n## Response Schema\n\nThe response for a request contains the following information.\n``` javascript\n{\n  // 'data' is the response that was provided by the server\n  data: {},\n\n  // 'status' is the HTTP status code from the server response\n  status: 200,\n\n  // 'statusText' is the HTTP status message from the server response\n  statusText: 'OK',\n\n  // 'headers' the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n}\n```\n\nWhen options.getResponse === false, the response schema would be 'data'\n\n``` javascript\nrequest.get('/api/v1/xxx', { getResponse: false })\n  .then(function(data) {\n    console.log(data);\n  })\n```\n\nWhen options.getResponse === true ，the response schema would be { data, response }\n\n``` javascript\nrequest.get('/api/v1/xxx', { getResponse: true })\n  .then(function({ data, response }) {\n    console.log(data);\n    console.log(response.status);\n    console.log(response.statusText);\n    console.log(response.headers);\n  })\n\n```\n\nYou can get Response from ```error``` object in errorHandler or request.catch.\n\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n\nconst errorHandler = function (error) {\n  const codeMap = {\n    '021': 'An error has occurred'',\n    '022': 'It’s a big mistake,',\n    // ....\n  };\n  if (error.response) {\n    // The request was made and the server responded with a status code\n    // that falls out of the range of 2xx\n    console.log(error.response.status);\n    console.log(error.response.headers);\n    console.log(error.data);\n    console.log(error.request);\n    console.log(codeMap[error.data.status])\n    \n  } else {\n    // The request was made but no response was received or error occurs when setting up the request.\n    console.log(error.message);\n  }\n\n  throw error; // If throw. The error will continue to be thrown.\n  \n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n  // return {some: 'data'}; \n}\n\n// 1. Unified processing\nconst extendRequest = extend({ errorHandler });\n\n// 2. Separate special treatment\n// If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\nrequest('/api/v1/xxx', { errorHandler });\n\n\n// 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\nrequest('/api/v1/xxx')\n.then(function (response) {\n  console.log(response);\n})\n.catch(function (error) {\n  return errorHandler(error);\n})\n```\n\n\n## Middleware\nExpressive HTTP middleware framework for node.js. For development to enhance before and after request. Support create instance, global, core middlewares.\n\n**Instance Middleware (default)** request.use(fn) Different instances's instance middleware are independence.\n**Global Middleware** request.use(fn, { global: true }) Different instances share global middlewares.\n**Core Middleware** request.use(fn, { core: true }) Used to expand request core.\n\nrequest.use(fn[, options])\n\n### params\nfn params\n* ctx(Object)：context, content request and response\n* next(Function)：function to call the next middleware\n\noptions params\n* global(boolean): whether global， higher priority than core\n* core(boolean): whether core\n\n\n### example\n1. same type of middlewares\n``` javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n})\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n})\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n```\na1 -> b1 -> response -> b2 -> a2\n```\n\n\n2. Defferent type of middlewares\n``` javascript\nrequest.use( async (ctx, next) => {\n  console.log('instanceA1');\n  await next();\n  console.log('instanceA2');\n})\nrequest.use( async (ctx, next) => {\n  console.log('instanceB1');\n  await next();\n  console.log('instanceB2');\n})\nrequest.use( async (ctx, next) => {\n  console.log('globalA1');\n  await next();\n  console.log('globalA2');\n}, { global: true })\nrequest.use( async (ctx, next) => {\n  console.log('coreA1');\n  await next();\n  console.log('coreA2');\n}, { core: true })\n```\n\norder of middlewares be called:\n```\ninstanceA1 -> instanceB1 -> globalA1 -> coreA1 -> coreA2 -> globalA2 -> instanceB2 -> instanceA2\n```\n\n3. Enhance request\n``` javascript\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n\n  if ( url.indexOf('/api') !== 0 ) {\n    ctx.req.url = `/api/v1/${url}`;\n  }\n  ctx.req.options = {\n    ...options,\n    foo: 'foo'\n  };\n\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res; \n  if (!success) {\n    // ...\n  }\n})\n\n```\n\n4. Use core middleware to expand request core.\n``` javascript\n\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n  const { __umiRequestCoreType__ = 'normal' } = options;\n  \n  // __umiRequestCoreType__ use to identificat request core\n  // when value is 'normal' , use umi-request 's fetch request core\n  if ( __umiRequestCoreType__ === 'normal') {\n    await next();\n    return;\n  }\n\n  // when value is not normal, use your request func. \n  const response = getResponseByOtherWay();\n\n  ctx.res = response;\n\n  await next();\n  return;\n}, { core: true });\n\n\nrequest('/api/v1/rpc', {\n  __umiRequestCoreType__: 'rpc',\n  parseResponse: false,\n})\n  .then(function (response) {\n    console.log(response);\n  })\n  .catch(function (error) {\n    console.log(error);\n  })\n\n```\n\n\n## Interceptor\nYou can intercept requests or responses before they are handled by then or catch.\n\n``` javascript\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return (\n    {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    }\n  );\n});\n\n// response interceptor, chagne response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n// handling error in response interceptor\nrequest.interceptors.response.use((response) => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n// clone response in response interceptor\nrequest.interceptors.response.use(async (response) => {\n  const data = await response.clone().json();\n  if(data && data.NOT_LOGIN) {\n    location.href = '登录url';\n  }\n  return response;\n})\n```\n\n## Cancel request\n1. You can cancel a request using a cancel token.\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n \nRequest.get('/api/cancel', {\n  cancelToken: token\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post('/api/cancel', {\n  name: 'hello world'\n}, {\n  cancelToken: token\n})\n \n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n \nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  })\n});\n \n// cancel request\ncancel();\n```\n\n## FAQ\n### How to get Response Headers\nuse **Headers.get()** to get information from Response Headers. ( more detail see [MDN doc](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n\n``` javascript\nrequest('/api/v1/some/api', { getResponse: true })\n.then(({ data, response}) => {\n  response.headers.get('Content-Type');\n})\n```\n\nIf want to get a custem header, you need to set [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) on server.\n\n\n\n## Cases\n### How to get Response Headers\n\nUse **Headers.get()** (more detail see [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n``` javascript\nrequest('/api/v1/some/api', { getResponse: true })\n.then(({ data, response}) => {\n  response.headers.get('Content-Type');\n})\n```\n\n### File upload\nUse FormData() contructor，the browser will add rerequest header  ```\"Content-Type: multipart/form-data\"``` automatically, developer don't need to add request header **Content-Type**\n``` javascript\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method:'post', data: formData });\n```\n\n\nThe Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.[Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)\n\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"803c805f4b0b64e1508e41ed7e3961df57711978","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.7-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Nhs/64JXmdNhh8dYwS/6LgKkwwHRnZQqaajvyX4fvXe9ULhDls55/ENnzPhRTLfH3PJsEGh5WOGgWJ38Dgag3g==","shasum":"227ea5e5acb65ef160a75b8de2185ebae6165892","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.7-beta.0.tgz","fileCount":6,"unpackedSize":93288,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdnaKNCRA9TVsSAnZWagAAqUYP/18grVgDEnmyPCd/nqVN\nT1a/fSX8pNktAQvIBtLjmVhLX/ZAL07SAZnIa/8qb8p9CouZ4IpwvehLF1jq\nB9CRXY4dksJVCHTTfsJA5VaPFdS5WJSrIpYDVtegmLFoRfkRJHUfuzCWxwwZ\nAirbdERMPnbtalojn7yuQwHO2qLHEYzEDJ8g1vqylZDoPmOR8Jh0WFhBbd+Z\n0l6XW16qEcEM2rDSeEXOD1Yqde+n2EKueJiWngeFTLTx8yf6d2wfsDM9om7X\n99Ofy8A2Zx0kdVt6YoVE+0yjEEgLRY2cWEwGWYdOnDNBOcnlthitAzripjlb\nlOJrX1oSeWZ267e8D6DY0KZnOrKL3/U2TeoTr2TNEgtHeN9HDtDLfHeQ4Gy4\n2xWXgCiv0c44jpr83LhfGV3KnDZWwKuBGi9UlbJRejTagsi/sZPka0ZYFn1E\nYtqL9peaTF2YsqjpA/PElEe7XbRQk1oYxS1q8fKXG3f8+Wy8aQis/0VmjIf2\nrBT/y5jQpuTmDvzcQagJWMfm/5dgfDXTGI2RJHKVDlLdQ/pMwNbEltMIA5w8\n52xSqWuJluLTUo/sGoWHISLvc8oEPdlz9SX4Mn6JhmERPxF9Km0sbKLdeobS\n/pGss/WBFmyx86F6YGwIfDFnwzykjOkjzmUs3uBKsW0qQI5YDG3gFgt0Mj5H\nUDSC\r\n=TKet\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsda2NDGybhCuuM3+YOuyDE3S7LDLBLckYu7LJ9cROVAIhANPcDxkd0whyaA/iLr0qHTuUubLytTTAary1U7ejSSKZ"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.7-beta.0_1570611853242_0.8469510150923805"},"_hasShrinkwrap":false},"1.2.7":{"name":"umi-request","version":"1.2.7","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"86c1b7dd0a3ef1521c64439ade569d42d7dce091","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.7","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-bbF2S7kycS4dAINRtCxLcOhlNLg63xaaYjSKGAiximSlOZxUOKtjDN6t3sTIHcRCNjN0xxBhKtsr1LAR65CYpw==","shasum":"079cfef0078d0c8ede636fab9f82e499279d3565","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.7.tgz","fileCount":6,"unpackedSize":93387,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdnpr1CRA9TVsSAnZWagAAm4YQAJHTwglkBsHnFQ7+GqBO\nJrCdiQUwL+FdCeKO2v9ghCFNuf9piX2UScofHKZSLSqEz/c8g2qEApWrkTtF\nbbJv/yqEo54S//8sMctKQAiyj9P3mRB4pRZtexbJANPjxhPUGpYRw1aIWZ4t\nHKHlUe/4+7FSlX9eAppShLuD+jI7TJ1ueFh7LAjK2p/c88OK8abY43MZBm86\n6IWIvPXimxQc9x5w2qgGJlvTVrz3kFIUsUq1ybwNuykSWjvztfLBqVW5pS2N\nUTgrL/rtuFtcFKARKMTztfZ5Bi9Gl+MAoncwpKr4zrKGCBlZ+JG+Z5p+ksUx\n8IPIAr5xQ6eFX7u/FcKVKZydA+2KbdTumWCGLqCXw+Ope1ZwDenjaP9mlaiW\nrlCrQEA4GBVR6z89ASdEGbw/nQ9pRpU8RpTyPHCcBVXnC9k1X+LrCx8mXaXm\nS9oSTvWn6c1j+CP0G3VkyR0E0je2oIhkembhvbKgOebiWYmfmV6m66suorjk\nedmLccXpl9Pf2RUruN4WYSPDoaQzfXwFMQiiRjTf/wkejHzNLZcuVfwSLLT8\nvhO38gphUCC2x+prNd6AWHLpX6Zu8C93HAtRuNSlKhxv3lObREYinLo5vXRu\nqQ12GjDSA0XZBZJrA+BklZ/63tjukgo96Ct+cdn9SD3ax342VjHroIAkfyfx\ne9ET\r\n=rc31\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCCg+pqRtojEdJZI5RfC0q/GAQu7hzBDZjPEKbgpwzW3QIgMzH5JJ9RGwQRIZ7tGHHBli/3c63iIDF/45ZryIKdeDs="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.7_1570675445022_0.22280336466729556"},"_hasShrinkwrap":false},"1.2.8":{"name":"umi-request","version":"1.2.8","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"af4c10ce204f3d143cac331538512a13fc8cc22a","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.8","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-EgKcTtylh8ka5lzcIBfrJ7+9K26lQ+cQjuBh7wIxzdiw207Veot0Ya+cDSAQHXn5+bI4QVU42hME5L9PnzY6vw==","shasum":"9e5636cee0945cc17fe15201a35670b240568d25","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.8.tgz","fileCount":6,"unpackedSize":93814,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdovNbCRA9TVsSAnZWagAAnFEP/RovnbjdXH2xt6MMf00z\nvbRt93cAXVodswc2/5w16z6uAuo5pOPf1Z62k2e23cWs325IQMyvBlrTBymm\nNjRuqhrnNxZiEkFyrFcWfpeOBDb9WQ3H7k2nP4IJp4QT7rMpDzlMIJ6d2Ybl\n2bCz9aqlAyH6ovSywd7u00h7kbXvYB9nTqsHQbpFJaG1DEvw2LOzA4eSt8Kr\nkQQVcc579+LA1GzB8sFXD4LGqcjCapf/uhblM+D0C1HkDxv/bXyrTj3KkA1B\npvRe+cFmYS9goGwcHW+vddou/yNkgY8VWoBD9NSYETFKiTouteLsRKI4zEXh\nO9NV3/G7HNbM+yOuClRYYJ5T/AiVdkC45taDU8gLocfJMLc6DKvIrpOsK0tP\nl6N1FtAOIM1YtHo8/VhTcQ+FEDjCOqKDBPwVz4T34O7ia1MynfIZTXO+PTIv\nMxU2L8JD2y9fS5twGwVeCi7zy7SsEstzPoWpl9HJRnT+G/hDXIy7EO7zMw83\noFKgGI8qOjFr+fmV3VH1TehWZQO+YcYC+Sjn0PMR0c8IHdz1Actnrjw4KYyV\nhnekBY5iGx3PZ2sYN9PP9YDKgsStxRCtpYZtxO/gYGAIZGcv8tjkCD+tRc4A\nKsq2ampt0PKIzL11HBNJSA/xtX/T7JSB3rTRWoWo+fVdS6Rg3cblu6zF1FdX\nucAS\r\n=kfy/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCuFqMbQ7A8D/2NNVXuq1EvIbEPqdAyebzmy4LUMgbveQIhALjEFdmGzWEx96apTlnjoiKCl0ks5cgXX5NqGDJV1Ttk"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.8_1570960218856_0.32545604194974476"},"_hasShrinkwrap":false},"1.2.9":{"name":"umi-request","version":"1.2.9","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","query-string":"^6.0.0"},"types":"types/index.d.ts","gitHead":"9f5d40e7ba9fe2e2a02e456e1e914a52832ac21d","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.9","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-6HzmNc5YH3X8OCq8R3Vuc3ykcYdKE67JhdHmR6MZ84VVf+zXvdKbTzfP6uzH8MTEfBKM+/m7onQ07bC4jdEbdg==","shasum":"427292c362477a4fd865ae44a8004a09e06d3167","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.9.tgz","fileCount":6,"unpackedSize":96944,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdxqHICRA9TVsSAnZWagAAUngP/2rgT9WTvtlUX1V/luf4\n54jDz2aKsmg0Bp0yelsTEXvbknoBTkRHK37unHKDgBC6gId1L2fcq0t7eHSb\nw511s06uXocoIvYSAxwZwIdhx63T4O3Gz8HIefldOGuuVOgRU53C9Vqf0eYb\nOS3dCjS+H3oXLyvxFrU6QiNvjLSmB1rLxkV3L/jrdcBipCbBw1Z0pHdiGH7j\n9jHtlvNIty06MehnHelQ9tx7KTPlE2/FeD9HExmOcdOd80TEfp4sqyz17rNy\nTfRvesQ5OPQ7N8yV4ED3JN63AyG2edoGcp39fWJMvMzCq2JkeyWx2WoGBg5c\nb2/IJ/SwLKnHXpMSXt4AN2elXipWv8DoKgv8aKL6ZCc1jIsHNOiYqpcSgV10\nGRWjcmp8w4SD1W5pYoD5kikRKoOmwDib1nOueJkzj49UhUUGhJ2INiF51kgg\nUYyB8L4n/H/gVcq5/CIvJYD9bDahReKe3V/2DA2jUYk7kB+KnvMs7qkZTic1\nYu17f7glbcIz0IhBBKZWEql8Fm4cWpuStjUxcqJEizPp4HT4NxYy27yoFoft\nDFhlc9BvpzqVfxp5uxZg38sNwlXIbfKbL2l1fONCb6KXYpnyhtMF6IAVwggM\nzvZCxVYz5NvFHg/KLxY8xV2/JmmiLMgoSfpw+qFRaZ8G4P3OppVggkkH5SxF\nNoiG\r\n=KMdv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBo9S0JfOZiA5V+63wPy8AcRZlLhII+CFJ11ycNDKscUAiBHanBupLFrSsh/uf7FfHQDgtw7cLdY4Smz257Q9BmZJw=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.9_1573298631775_0.11906704457898454"},"_hasShrinkwrap":false},"1.2.10":{"name":"umi-request","version":"1.2.10","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"3a1e787f693a519902d543000cf5c035883e307f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.10","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-/0PacchYCigZnr8kBNPE0J9qCvbiYADxV5INvRGYAuJFMQOgwIerQLgNs4ZvjMz6f0HLQCqRZiaVd6FdnHFZ5g==","shasum":"d7e880590e5a035f1ddd5b15f4671bd02591e128","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.10.tgz","fileCount":6,"unpackedSize":99077,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd1ToFCRA9TVsSAnZWagAAX84QAIKJnB5B9fQmo5TErL6l\nTx4ORfX2J2a8dIIPEdGitmqNA6RW+mH6hif0Oq9nlXe6Xt6qqtgtL333Z7UJ\n8h2amuQtvoxQ3BexTDWCeJrvCOFoFA6ZP55+IwdxBYZ2XZJYgDfEj9oWvQ5d\nidMLU7GcHZsDWRTJXFsTJy6RC5eRxeovAQqd2CqXf2lhkTm5qElWK5klml2S\nM+K+GQfvYZIdpqKceAfPWU/FbPu0/RyEPmG9yxQk9wYxcSteOTFg0ukr3Cwh\nr7zQKv57lWsvohpbIoeYLt05Vhsyked9j+OFLYomnVkfUwhl12muATdRD6CP\nL0WR0rmWiPGyoNSEqUpvwyIe+14IT/IwVflspSmsJe40SthJcakFO/sCs9+o\n+S8byyIo7rAa+n5heClJW8dLg456T8qM9o66LJb6ynFaStiXBk3XqPKmFGVO\nBw28z/c0lrrY7QqMFEQdJBai98fTq1mSpZSBXZdeBwc7LVh1O0K9+551KQMA\nkipaGnJd3tNonMhTRhCQtErjwAjabA2mJDBM21XqLOwQEPp/ZBmD01gzmgs7\nEB7uQzmgffiWfvR9fkbNxfAt4d5PHKSp/aozLlbq+dVXoyAVZ6PpMNGkY2bf\nTFK1V0jZUl67N8W5zq/qcqDdqsEH/o4foj9ef81uaAScZGDbL1+oGdtmlYsx\n/WY5\r\n=kg4b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFnAvTD9vGH1yzKJmU+GWeIZj2ycGU+5xCrjQYVVJx3/AiBII1UlqT+kB5yxzY9T4JIJE1xlTrl2Te87OljI9Dgsew=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.10_1574255108859_0.6936902453071436"},"_hasShrinkwrap":false},"1.2.11":{"name":"umi-request","version":"1.2.11","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"eb7ed77ad69012bf21c1ecd756f0ecdca9e6c521","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.11","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-ODht2CraxvD8JVrG4R/2Vb152ssK4P/xONspCv6q/32dPYaIGwvI20QlWH3IdH2Tv3R/U/Q5qPmOMJ/hcZ3M0w==","shasum":"566455da506ff45552debc223f8ef0e2686e42b4","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.11.tgz","fileCount":6,"unpackedSize":98913,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd1qOsCRA9TVsSAnZWagAA9I4QAIZjzPTT+TjTkUHhWJtx\n5rhI6g0xVBcH3GJ+PUFp2GCV4eYiTq8MrkQtTEdt4WgTMtjUODzx+zLWQWXK\nankMXTg2YX1vVVmDRDpczosciosuXMvmtKu3WM8MhC37dmBcLtUmqdW7Bzln\nqhQ9ZfEwbkx0Vt05F72tK6QcLvOV3JMpxNIAeaCc0IcDbokqOi74+yZHZJ3i\n/5NZZXKdNU5nAYmc7RYMPiF7dfZkNjdtFYHY7Ma8u2IFd7mW5GeXBkHUJ/y6\nKEmXkwsW96BzQD7RVA0hH9JJneRnYbcuuoysRo9T2haRD4Vf+P7tSXI4qqJs\nS6cnp09wW/npziH1mzdpF2dwZyCmdki260fG4f6jFxPWSggrEuK9p+OIKS+k\nGEYURvwDzdrunBBDZkPEqP82X323cIIEcRA543277Q0dj8+HVsN2q2cngaP1\ns1kDWnNAFLZKXk1j6j+nwtwoyQjXNWCe77p3u1ceB+O/XUqv41AP9IpkfFq5\nyKZsIbmJpnKfbATeG75N83KHLxEVjRvP2ITatRy5QYJK2Gyo/c89dpogaWbY\nyui48hBczv4YVP5uklkaRWoVFh2VMQoqzYDM5Yfb0nVtocdsWxfGXB+8Ni1G\nX4OkeFk/qszzV/RzBCcpJRU3TLXnMKWCftMLPMCC08rzkQMOMwQpjvD8wbM4\nD5zd\r\n=XXJy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGlOsxaNdh7Xnu4HGlLdeXmr+Tupb/EIff1Vrm5kZEDiAiAN4/IjGmuLhpLOcRPTfKSIVh1gJcjAus2KNI2NT9PShA=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.11_1574347690841_0.5344288420844425"},"_hasShrinkwrap":false},"1.2.12":{"name":"umi-request","version":"1.2.12","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"8131592495ece140709db1dc2a7ba38498f12cec","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.12","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-DOcW7HyIB2DiVvLElZsWhjBWLdMArd+rLtjNIdJuu27MA6zeZi4MTmJBCZL2KqcDuyc7DL4MVy1TzHXaS2HpWQ==","shasum":"ab69289947201358194cea406a3ba345a83ecefe","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.12.tgz","fileCount":6,"unpackedSize":100204,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd6KDJCRA9TVsSAnZWagAA9NgP/jVTQj8SLD6uXOz2CfcN\nYu57L4rU3hd4+04l+dHZ/cU5FMlwQFjanBnMRDYxTM22QXAwajv2sDlJQwsq\nQHaUqzGT3a6aRFZC4Xj4MUTopCrX6Dd/SjtTywNSmEP4aiZavVKo4oPY83PG\nUQRGPIFox1I+Ee3Z6eA95uc716OBkCqmJGAlDwqYSTOwPs6aSbNSe2+AFPst\nhxNLoNAsqfNeDj5o0jzeJhFHO0T32vQpO7TCMRtWRy01srU1KA1D9AcgdWen\nYljJUhe732v8Sbpjm+zbjP/dlxvzYCXuOmY+A2rA0Qa+vez4qP1AJw3c6NH1\n0SeFojEPiH5Tk28uT7sDIcSDBnK8FI01zGEZVN/AtiN3P+ZvRXHHINlXMF9B\nRO6p6aBPnwfbbScne4M0rxrtFEJXZYYf3IyGd8xDZ9WNsUdeYDWqED4h+pDD\ncvvfcM/9KL6Hdyid5wSp4EWB5fya87dqsu4K2cK6FVqSke4RLtmbMe7xSvx7\n60DxvUxRC2mpS+mK7Uz0mxaDOOhlhKDEeoOmAMd5Q1U1yD3xN68dgw28/f+w\njfo669S5PcfYmr6i3GBYj3InBg7Ae4iSh85NNgedGilIp6qYWZxMCixc/bWM\nCbtwq8KHa8I8pU4AZfAy3Efurz/wBz6pIj+qBm4RW5xucWqw5UCScK6Zj84P\na6gk\r\n=G7IS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEkbGKjEujryapDwZiK6/ZkImwJm/abD6QOzZ6qPto4eAiEAjuCICB0X1tT3gZzPPE8cD6VybPorHz1jKGWoDtEuAAY="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.12_1575526600687_0.0835301959657222"},"_hasShrinkwrap":false},"1.2.13":{"name":"umi-request","version":"1.2.13","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"8b38e1c32c0c336ef5a0efc6c1234153dca58b9e","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.13","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-d9+Y16s+ffEH5g6ROh/mJgTqMXH23Pp8Ta43FX1I1ASpAET2Zhms8ii+JvPEY8/YoMCM5lyBcUDvx2UJOzJYfg==","shasum":"28879b445b47a6dbf50234df079d8a54a55570c7","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.13.tgz","fileCount":6,"unpackedSize":100204,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd7gq8CRA9TVsSAnZWagAAJTEP/0BvBv64f9pFgWNJNQbV\nuIw/4+C+/SxnrZ1DEecjsTpENruq0ZVw6Uid1aUJKLq+Bzst7CcqAPllC7IH\n4Yd9mDfVLtxdxE3vrXW3m0RpkOYOL7IGNCXWWhzF+1Z96Qe79U+LOqmvxR2Y\n74TZZF7+SkQMzNWK0oQmI4wV72dST8KBo7WMPBtSnYP2PuxyuGMBy1SWN9lr\nVvarOGp53UrC+NzUzrcWEXNKV/EqCVCIT+lNWvthBoYfLGt/+KrP7LfJraeT\nS1wgXEwnFXgioUXd92dezdm7hURuhGVPK/vIWQ1Vqx2/ObcWgFmjkDq88b77\ntD7IPKYp+4xXn2ls4RJPGHqI3enPqQfnbm0vR05RC2fNqJp5mMDM0Awnp2xF\ngWvINxPfDI3CKcREKGu/iiF9tetWUUDCw1xOfGXv2adci29a5rfcHGH9kip1\n0w5mutk6FHJOmO58n2rRbvUAQ+O3XjQGJrhMtUqp4IxKb+zzBob+3QCBNJPk\nXRswFTYJwyxC5+bh6k26BpyeAcOH5T1N94fSm7/dBjUmSCzT2HYEElAv3XfU\nlskPBU7NuueIO3+/EUisRhQt5QtbZt41QNo/gGOrdWaJamQM7Tyd4/R8vni7\nUQTYAEU81kwZQIrkYdxL9QN1zWAgwPTS5jRJQEwhPAzlLUhXpH96QoD/FtCx\nMVXp\r\n=wRgh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDL7E83KFpvZLRUs2k7H32MyeTYfdQqVm31LEqxIz3B+wIhANo7bsX8wVYF8pNmZvlLeIHM6CbvZhDG2jipkNo2MLWi"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.13_1575881404082_0.898257482341283"},"_hasShrinkwrap":false},"1.2.14":{"name":"umi-request","version":"1.2.14","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"6374e47fd307db09c0071553cfeab72c1c2b9646","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.14","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-vXHvyJbqYHLjuUoXf63PqtlEG4Td6mqvowAVi8zlRyrVJ5WpfszHGgrWMZTf5cF8eICH/Ub1f9e/gG2W0d6Hsw==","shasum":"ff50a324e1c03e5ca8879af32c12a8c6e4981458","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.14.tgz","fileCount":6,"unpackedSize":100550,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd7i4CCRA9TVsSAnZWagAAXMwP/jKFud1JvCRzuNxqqL7z\nU+xu/xabJxHFOdYSRCfnKRA4UAcmooK/ZH79RCYiU6sU2t9ddk1TTUDvXhYC\nxJ2Vl5M1oo6xlKQLwuIt0Toz/KIJ9crSLQuLUTEwyvI2TW1QZTpXncyUq3Jc\nzX1VDsj5tk+l2IitcQMwJv8XSjCU+naIJjGL1P9y7Dx7HVJpkYvkY846lxli\nOjb6CYAkXnUB6zCd4jo6Zxpxr8kpBH4EOaTh78OxqMavOcNIYGAi+/FFaTQv\n/2vkDHFlkqWNaLWjX52bcXGQvv146wg9wTTW6wFQIl5yrl3GP5fP1GLxMkYn\nkLOu0EmknNQyy/9KjT2b9SRdGFiB8fzylBLFPeWeXjN2sO/Syj1I46DkiJ9s\nIbKC1d7pyTverwOZ4jgLtqpVlDgxRnADG5bqAtm+HJGhQ+THXlzXONrroNqQ\ns41/T4T9AWgem/Vk8K4jnYdPPt2TWX1wKrsDxGuYXyin6vIALyrFzEJGW88W\nBSp5nNCGiFtkGU8tKhbnAFeQ/w4g2OplcnMIOSLfEDXTv9qPkDr8+63J6FZo\n8iiknN+CwzybczOt+ApXg1z82fzt5KdceQ8zqdH5gXrJHO/7fts6k2eiil1E\nepSY4561pC+ulsOBAXR1o/9X5ftuJC+IacdyVwRc7hfdyJPjMzat5G74iDgi\nU9m+\r\n=jWQe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNpLZwH0xB1yeh2IHLWh3mnpkiN3vxak28MVtvHFUf1QIgOU4CJ2RMarFTLZTiCt6IqX2KSKFktK2/smUnm2yFGd8="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.14_1575890433579_0.634161444241665"},"_hasShrinkwrap":false},"1.2.15":{"name":"umi-request","version":"1.2.15","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"b52f2eab91a04f6363da4255b9dc8bc69bdfae3c","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.15","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-zgncuyUDYBVIevQ5QrSFDKdFgcpv/Xznq3x+pE8lNg4Jyjmy77OzsayK8YrD50qPzG9lmqTUgp7VN7v9y6w7bw==","shasum":"fbd93ad0256c702e48eca73ac10d0db670c67145","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.15.tgz","fileCount":6,"unpackedSize":100598,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd8iLmCRA9TVsSAnZWagAAZ2sP/17tyR+aY2wpV1M0F3OP\n+4FsiLVnr3i6N7xq4CZ49WAsqc8JqX8T1FYv8ymc5gldj0KreZCeA5fmo75U\niIYVeaALgVJfJY8Fi8B0RC7h1jrdN7sbglUVGGUbXcXqpifLoZfAw9nCQ3ZW\nFZV/JZKHz5F9QqICxdISwS8RZZEJp2UUBX9YOtsLyxDYJkqAHv3YV+j9Qn1Z\n3U7QtLtcbRnVm47RSTgDGxKWxvTTyMaCs2llUmKgF7MrJlxwvwi1wF7BfuBX\nJVk6x9g+DaCuiDvd2NmTBZl0Q7yl2fkLNxAe+U/v65wViPqGnQwv9fuUz/Uk\nUbuJnXZ7AzvUTz5iC4pZsnvCsrHSrATN/DY4itDZwvSho8pXM8Y/LOu1g/p4\n9Z0dn1KkzcfLD9YUa6L39umcX0326G8HXC4HBQ7TkOxf9LG1FEYZAka1wpSw\naT1ggj+0QbJxN+VoQ3kG4A/YAk4phk3Bt5pRK0e9FqS4WPs74Ob7xzPPD7uB\nIgoB8g94vt7OsaNyBjO5SpR1HFf97fgzEWDSQSo/kgvKtzlv2sz6yWXDa0P0\nEzzLI8axd4KTfEwHfoO/KZjMuMOeXX79IlWp8fZUGfoYruPPwmrZrNqJzvWd\nX6wOpICLjsgPpWqRGO0vaseacVs2g2FXR3jspShrO/AyGp97jUJ2t5zUd3Js\nwCg6\r\n=Ut8k\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBWM2XOpn9Al2T+4aDu+ibUxnedmdf/MVLUhaq9Qbs14AiEA54QgSr2K14yYAwHsrjbebt4iEYTtmvMvJBRFn42Zhic="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.15_1576149733832_0.19806416632210522"},"_hasShrinkwrap":false},"1.2.16":{"name":"umi-request","version":"1.2.16","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"5db96ac95cbaf159b863130c237ba3e0e982993f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.16","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-UiktwKNZG9LhyCstM0uarL4/+YcShpaZjkKSxmH0nWaoB0Uq1t4LUF/JBTZHTl7pQ713hBWvB34nrI1cbQT60Q==","shasum":"b17af482c7c07d813fd16df2f583051491bba981","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.16.tgz","fileCount":6,"unpackedSize":101840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeAdPrCRA9TVsSAnZWagAAdXAP+wRuQi+rlYTYpByIZDP/\nKAlKvZAzlMrzxNOc5nmeuBUtd7GaXNrKZMV5d0kBDhCuMkQZkOJi04gBWqJG\nZQ0DSPKr9DgCs+b+6pE6T/VfGWMvHLjiUCuhr7oXRtnR5SejpMMWJsZzKQKl\nrC2tj5A0n9KEB+D8WGk9E2x5VJiiEz0yIGvVeQsLPTRG3+H89AWTSH0WIfo4\nNUUn+6/P6Hlvke12icb2bCtmk4QvqX6b3Gd9cjt0gL5id4j9Bki0t0bqhTpr\nvKy2wQIekIU9+WP343G7KqJmb9relsYkqRmuNMfd69gI38H1pF8dwAfz2rH/\nFWv9jWcawd0jbk5jv+pok7xD/S6H9tuO9errrvLO/qU1kujE8As5oJpa+a9a\ncXoJovlp4a8uzQ0Iyw8jDfTdGB9PaHLQk6LIpS67Faya+MXXCHI9QEvniI07\niAO5tSqWpV0n8msCgpMiMSTha/i+Xg+ffOjfYZpatM4AtATfwjAr1bJ2m9tg\nM1y9wJJC+hnIDIAqYqYY6rbycTPPAlTzhk1jmImluDUiQ18oZc51OhkFXNU6\ngT2DcuPRhTUV9DRbihTyOy5exy6Lfoct6fkjgTq/084bjJovQV6Vqu6i6Lv/\nGPxspD+2xTufIsqZ2DjyJhYfrEa1EIy4o7X4frZo1luSOt/soCjNm0bXm9Yz\naRG8\r\n=xFiI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICnQ4wK6HJyWR05VwrAiCKwNUs8RXhKRCJlNFQ2I3+GMAiEAn7s0JC4euJQTcfmS8yDQAAR3kDgDaMVud6NsppJOdDs="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.16_1577178091412_0.4951541537169091"},"_hasShrinkwrap":false},"1.2.17":{"name":"umi-request","version":"1.2.17","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"2fe1f9baa1f0ca8085765d2bcc0524a1e9072821","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.17","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-LEsFsGm6BhXZ8tx7uW/I+O4PdbEoeXZwCE6gx/QCqfpbBw2qczOvLvLCVDP4cbNioVJHkOPqKqpFmsFVbsmwjw==","shasum":"817a4858d60a3d453382612f5873a7a0299a60a6","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.17.tgz","fileCount":6,"unpackedSize":101840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeBHFHCRA9TVsSAnZWagAAImQQAIG45IIi5mtN1LVZEAsr\niwcGJ/HgXxV43KQdbCx7khmRzntdAOspmhNshVhYr2YxBIQJVBmEVaHRh3m0\nHKbjxjw74DVuKdzFlLNzV9arxg49NnOyydgz31BIj2oihFVaDGHAUehWdVuD\nuHr4hgtqgSnjX/AhJ+FOzFThBCLXzf2DA5SdiY9mJ4KQLrnXLQRd4yiEWyr0\nI/WYJTJK1zoWX2csodhSj7BbXVKFz4M1oM2IFxnj8ZZDVTZqXrfFLii5O2ax\nMRHCISC6tGWMXX041Hqb6s9F3kxRkIKS1lbzOrsyJUWlK47Qcs9nXaj59yn6\nGkl7CLeroC0Lr/NcMB9b4CHD2qoLyLkwlvdc0/6U+zxFZ1As7ADPA3y5vIXU\nn1BxbQZ5OnhD4FRlXPK4CYEulfl3CjQhvyb1KBpglVdg8Ex0CGALc2WjyR+S\nTa52hrN7Rp426/FyujEB9+F/FWZ/rcEv8u8Mof7Gq+r6k8N1jsLx7in6i/K4\ntcxMtjdXBCIaLyEe1DZzRHB4s7y5Q81fllc1t8Ce7X7bj188C1oRt1f3EfUJ\nF5vSb91B8VLPpr5s25GT0+6bChGKZmFYRQrRpRtzsMM4A3AHHiC5aL3hGI2u\ninafzv7v6gwqXXyYATxK5dLHgxSQXLptHNeNaL+gD9VzWftael9Y0ttPWRRh\nGSCR\r\n=p5cE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuRcjgbjcIXcQH23vXIl4ufH8Qo2444uvsfT22qgBPLgIgCi85IEH4Two0y+eJqWkcESAe/a+mLemTWKqsepSZjnQ="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.17_1577349447030_0.7976427328693798"},"_hasShrinkwrap":false},"1.2.18":{"name":"umi-request","version":"1.2.18","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"192b5a54ef47edfbb1246ec15582ac23d3d951a4","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.18","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Kyd9wKgkfzAmA1M8oT2bmb6TztOYQMB5pC5DZdaodv4gx2S+36JqEVg0aahXULGLD0j3G/7TbudsFCNDnoo+vg==","shasum":"d5e0c969f6deeff0cd9785c820fafc2a268b84e5","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.18.tgz","fileCount":6,"unpackedSize":103278,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeJVGDCRA9TVsSAnZWagAAgOQP/3KRONHhwYM826WKzLy6\niyKokf3d7WWQZjtdKs8Ri79L36raoUptwnhGElZeT6WT3k0ON5W631rF9MSe\nydQ3otBM7uHkaM2rn6KdIKzWraQYeRgGdsPX24VNBgYQrhuP3w0VDL4M7lAO\nPpzpW5hnsYnKrwF+JNCv0toyyfc+uU+K1f9xQhphtKA4yAHSzskUBwtV7yIJ\n0scnz21XkhCdlgvELPbubCuPPpPqhXPyuXTuhvDAdYgtTKBJV9goG70X/kH7\nfHKlhWpVevwfr9e71XiTcDwN3pb3mL0WOW9sLqcRtkhmNFfLPWgjPljX+/kC\nnnDmo6WtSQMI/oko/PQU5H1uqCxTwAEL9FD26R3xys3e5ivjUjSQjSWNv+TL\nO65cAGHB9zYp9QLp8ZhILVe3z7qxjP9eXMwjiEz0mtOrW2dnWWzwyw+Q922Z\nFr2MT8EeO3qVtdsIcb+q7YEVCNbcT3tXLdCANUdytEFCoYtgwlcVKavl0HMJ\nBTRwKzHIIQd0cZzg9vMmHjswysm2vXmwRN6g4arbpiYyKYO0bEvAXdOTbdm5\nx+2t0mWfEdMDOwGNmlBR6yONMz8c95bRy+BohCaX3ueFmtVrBQZv93RCstHr\ny4cjZnIv6ZfUm4SNsUOX5srXqd2II8kAhtdnycNVg6jrPmp7UDuxPq07AKkc\n+GBT\r\n=LY3d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbuvdelA2IWJPqj0TLjtNz932vVl49Q0acJCbGUrK42QIhAIg84DBxW7lJ9E5fW8kH8wqI+1U0b21vmYFBNfTRbRy/"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.18_1579504002776_0.2088657120057955"},"_hasShrinkwrap":false},"1.2.19":{"name":"umi-request","version":"1.2.19","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"d9eb1299163a2c80d8bb448a72809e66c4fd4348","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.2.19","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-gN3OyEJGs+h4Ly2UFBL/5vhFmTM11VJ3OIq2AB3tq3PCVwqwpjY09MAwzCT4rr8Ti02kdxcPaAEUllLP5XvJRQ==","shasum":"57ec16322506674f2d6392d553119829cedb1589","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.2.19.tgz","fileCount":6,"unpackedSize":103372,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeS6KgCRA9TVsSAnZWagAAceAQAKOKWWLh+HB0XTUa6pP4\noO37wQiyOnB+xvSSK5Lkvk0h/QBOXC1aA7hqb52dEDG8Jyy8UmEKwz/FZMtw\nBDTLsncQBcOTwX8dvR2z8EyK38b2zP04sc6HOsnWEfNtsbZ1bI9QJc5F6znb\nxEeS1JCiQfjigpjSybzJx7jYUtc+jXjkmIhnnS+vrLvXM4Ah1TgdDfmS07vZ\nzrrSSIVGhO9DPI1c66kP53uOvXdzRPXnHuH1I45sFEoM7mDZLla57LRZgXcv\nQT6eAmNtwzfCUZAD1JhHwEt+a9J4vBPqCy8i+n950Q6gEmw4JyavMpFE7uwZ\nV130xYVaQUUxBFzxst8ew/Lr8o7XWW1hr3jpTipdl9//KxXyVc9XuV5XDJEa\nWXAHcF6bl4pTNDl32bZRoNu/j7fGcGLiS65MaVButWzZYKeq/chOfGaUIyCM\nPB3/2CLRbez5651Fb6UBPXu/FA7PQ1sxBQmvATSEnwI4b6PUCFnHZB0jfKaO\nGpVLscbQnuSJ6T40N6tg6BnYbVmldCnU3iAL63LzaWycSO69puaqMBkxu7QG\nXl5FGFVsvDiW8V47zEKyEF72izg2ABvG7m9gr1JQwG0qJMuE+ZSN8tmjyRua\naFwxb+33idpWlwn+jfBY83xlI1IvanvhD2CrWEe3uo5vMStEHzuntorPAbVC\nF+jW\r\n=+AKA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfiekkuXcQem5KpPx6EF8ou7yrjQkXid93gk0IpU8JUgIgepUkkJ4ATCU1nuIKx4fn7WjmkbL036Sm5Z/TMidBpUQ="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.2.19_1582015135916_0.39371019976193034"},"_hasShrinkwrap":false},"1.3.0":{"name":"umi-request","version":"1.3.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"a7db8c062d92a346f987788b08f313eb82ff3f8a","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-aiZY5NYK6v+7LdrkVk756GH61j6XNORVRrI7DeZcKBqe3UMxzQphts8IOpOJXtZfI9W7wAqPzbyPLwFoSsopMA==","shasum":"367cd9ccccfe341baf5af7ca873575c03f19f9d0","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.0.tgz","fileCount":6,"unpackedSize":109102,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJex5o/CRA9TVsSAnZWagAAMj4P/05/DsQPF/KJHk3SCOhP\nexwNPsvs0t6WuEQ8Pwwe7mVAw91tTimZ4XVtjYDkLfwOlUuWQFdS9hfOjQay\npcjqoYsWpJqZu5AJC8e/5jmFTGkTyZCdCFPDdpsc1dHb0yu8YN+HDszdkcsc\nhdb1bGRK7ijTUk65l5kVmE3TyEF8cCXdcoWmVkTIHob/p8WULpYNtcGJxAZr\n0oHA5oft2tXsbvDJV9v60AzkcAs6c9UFeuIo+CrXOshU16ywlJrSfmMvdnac\nPdRMrq+n9OzlUk+AK9R0xQaLBmP5+vu4N9Qghl15H+rCKIGo9Gj+LRaXZ3GU\nVq9ycdS1sVYWR4eXXauzW6MCY5rrvfxNUeDEQdzpBLSohuq9/7pyzbFMwSrb\njSW9F8p8MVAXiFwFV2OqRDZly69YN0coIt7+r7meNA2Bh7s9yfSo1Hpx1lni\nU/9j4GzWZllqviLsd2TfsQHnbqgrZaoVyT16WaZzm+4UkVkDiDBU1f3AfvUv\n2e4mcXKwUNgrI5xNUpWU7FpE5KfEv5Ghkug0Tg1OjfeciPmVJ81DAoZJp7OK\nxkxNeXk0SbdVcezildhsqkfD4hQVLZPNctHu28Vi6VOqgMOQJp+ScMLh35Um\nl66iryubCTNja+5wGZNNJNgJm04k6n532Ey/8sZRFOFJe3Na3n9qo//oZUn8\nfNDx\r\n=QVFs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC6j6IQcf1W4LKpYz6VqTrxLU8rhwNyIqqo+5fVUzsVQAiEAieeN3VO0zBEN2jeApcqoPcm5cQqqv8k7UIX4fvzjKzw="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.0_1590139454768_0.7918753881027039"},"_hasShrinkwrap":false,"deprecated":"abortSignal_error"},"1.3.1":{"name":"umi-request","version":"1.3.1","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"d9eb1299163a2c80d8bb448a72809e66c4fd4348","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.1","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-lIw7yCdeLzrpgDkFBNKzthA+EY+W+qNISXIybRReQa/CjFSVRskjfHHlHRhx/i2+W4u4+ea+AoO7rxcvdfLk4w==","shasum":"ae64c757082fd9f16c76ac0b3adb373d1dfc4de2","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.1.tgz","fileCount":6,"unpackedSize":103332,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyAxkCRA9TVsSAnZWagAAe34P/3oLU9rjgA4hBbH/6SyU\nKcTxLUxi1Twu/l2H2MFk6PpkKPMpcykPKM+AfU/eJ+8W6vkL7na1JuLXTHWS\na16a5zqEQ17cAEdtF3Th2zW9jGsj3WbkHKqFUsdGiQ7ZDt7axSamWLIOK0aU\nHJd/JFzROXAGilP5T2lwT3zizmzBdMAL5q6y/d3B/vcmtcdTHc87J0Ys4jLp\nL26kGFgoK0+ISI8jqlt5ClZHmCnZxx75FPOwj3hdNbpct3syKOLjLkGTrz2D\nJ8OQfWRbFXZdRvoAdEUggQ+eV+WUAQPhWqwbrDJnPv6nrPBFY77asvciv/Nm\nGbb1vRa7Buq6NRkbQZnuB97NEC1X8GAQUSjxHs9+t5ogx/kk5o+NcYw7q22E\npHmCbIjhM4HT/iRJTzalfxUsMQgK2fjjKDZlKnsDqLbb4Q0VtNv/bv3tUc7k\nM7TRK6impF3vyfzy8Ayz51M7e9GEbeVIjTjs5Bep2ZwWZhw/vKXqV7PYnRYC\n/mBg9PHM5GZCSObX2tjAsyblfIp8P1+JgZcQdvenEVHybyQZyr5IJiwYbTW4\n2gled41BXjJ8Dd6CR4rRYFzcxOCdJEL6znRVOIHqKUlhTUU708LUEKrM2xYW\nFUkJVqlywKM0tDstGuUwKz83LC2En0i/WwDMeng2yHz7KHEahPUPPjppk4M2\n+VDq\r\n=UCZo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC5eeUWqt3fxxa6KDytNPdIV4oDYUR22amP0syEjnXjIAiEAl9at6DZa65RORhVv/sX4kw32wopUe7UFLvALizkoFaI="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.1_1590168674273_0.41926000544530817"},"_hasShrinkwrap":false},"1.3.2-beta.0":{"name":"umi-request","version":"1.3.2-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n---\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features             | umi-request            | fetch                  | axios          |\n| :------------------- | :--------------------- | :--------------------- | :------------- |\n| implementation       | Browser native support | Browser native support | XMLHttpRequest |\n| size                 | 9k                     | 4k (polyfill)          | 14k            |\n| query simplification | ✅                     | ❌                     | ✅             |\n| post simplification  | ✅                     | ❌                     | ❌             |\n| timeout              | ✅                     | ❌                     | ✅             |\n| cache                | ✅                     | ❌                     | ❌             |\n| error Check          | ✅                     | ❌                     | ❌             |\n| error Handling       | ✅                     | ❌                     | ✅             |\n| interceptor          | ✅                     | ❌                     | ✅             |\n| prefix               | ✅                     | ❌                     | ❌             |\n| suffix               | ✅                     | ❌                     | ❌             |\n| processing gbk       | ✅                     | ❌                     | ❌             |\n| middleware           | ✅                     | ❌                     | ❌             |\n| cancel request       | ✅                     | ❌                     | ✅             |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n```\nnpm install --save umi-request\n```\n\n## Example\n\nPerforming a `GET` request\n\n```javascript\nimport request from 'umi-request';\n\nrequest\n  .get('/api/v1/xxx?id=1')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\n// use options.params\nrequest\n  .get('/api/v1/xxx', {\n    params: {\n      id: 1,\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nPerforming a `POST` request\n\n```javascript\nrequest\n  .post('/api/v1/user', {\n    data: {\n      name: 'Mike',\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## umi-request API\n\nRequests can be made by passing relevant options to `umi-request`\n\n**umi-request(url[, options])**\n\n```javascript\nimport request from 'umi-request';\n\nrequest('/api/v1/xxx', {\n  method: 'get',\n  params: { id: 1 },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\nrequest('/api/v1/user', {\n  method: 'post',\n  data: {\n    name: 'Mike',\n  },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Request method aliases\n\nFor convenience umi-request have been provided for all supported methods.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\n## Creating an instance\n\nYou can use `extend({[options]})` to create a new instance of umi-request.\n\n**extend([options])**\n\n```javascript\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  prefix: '/api/v1',\n  timeout: 1000,\n  headers: {\n    'Content-Type': 'multipart/form-data',\n  },\n});\n\nrequest\n  .get('/user')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nCreate an instance of umi-request in NodeJS enviroment\n\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 });\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\nThe available instance methods are list below. The specified options will be merge with the instance options.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\nMore umi-request cases can see [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n## request options\n\n| Parameter           | Description                                                      | Type                      | Optional Value                    | Default                    |\n| :------------------ | :--------------------------------------------------------------- | :------------------------ | :-------------------------------- | :------------------------- |\n| method              | request method                                                   | string                    | get , post , put ...              | get                        |\n| params              | url request parameters                                           | object or URLSearchParams | --                                | --                         |\n| data                | Submitted data                                                   | any                       | --                                | --                         |\n| headers             | fetch original parameters                                        | object                    | --                                | {}                         |\n| timeout             | timeout, default millisecond, write with caution                 | number                    | --                                | --                         |\n| prefix              | prefix, generally used to override the uniform settings prefix   | string                    | --                                | --                         |\n| suffix              | suffix, such as some scenes api need to be unified .json         | string                    | --                                |\n| credentials         | fetch request with cookies                                       | string                    | --                                | credentials: 'same-origin' |\n| useCache            | Whether to use caching (only support browser environment)        | boolean                   | --                                | false                      |\n| validateCache       | cache strategy function                                          | (url, options) => boolean | --                                | only get request to cache  |\n| ttl                 | Cache duration, 0 is not expired                                 | number                    | --                                | 60000                      |\n| maxCache            | Maximum number of caches                                         | number                    | --                                | 0(Infinity)                |\n| requestType         | post request data type                                           | string                    | json , form                       | json                       |\n| parseResponse       | response processing simplification                               | boolean                   | --                                | true                       |\n| charset             | character set                                                    | string                    | utf8 , gbk                        | utf8                       |\n| responseType        | How to parse the returned data                                   | string                    | json , text , blob , formData ... | json , text                |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json'      | boolean                   | --                                | false                      |\n| getResponse         | Whether to get the source response, the result will wrap a layer | boolean                   | --                                | fasle                      |\n| errorHandler        | exception handling, or override unified exception handling       | function(error)           | --                                |\n| cancelToken         | Token to cancel request                                          | CancelToken.token         | --                                | --                         |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description            | Type   | Optional Value       | Default |\n| :-------- | :--------------------- | :----- | :------------------- | :------ |\n| method    | request method         | string | get , post , put ... | get     |\n| params    | url request parameters | object | --                   | --      |\n| data      | Submitted data         | any    | --                   | --      |\n| ...       |\n\n```javascript\n{\n  // 'method' is the request method to be used when making the request\n  method: 'get', // default\n\n  // 'params' are the URL parameters to be sent with request\n  // Must be a plain object or a URLSearchParams object\n  params: { id: 1 },\n\n  // 'paramSerializer' is a function in charge of serializing 'params'. ( be aware of 'params' was merged by extends's 'params' and request's 'params' and URLSearchParams will be transform to plain object. )\n  paramsSerializer: function (params) {\n    return Qs.stringify(params, { arrayFormat: 'brackets' })\n  },\n\n  // 'data' 作为请求主体被发送的数据\n  // 适用于这些请求方法 'PUT', 'POST', 和 'PATCH'\n  // 必须是以下类型之一：\n  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // - 浏览器专属：FormData, File, Blob\n  // - Node 专属： Stream\n\n  // 'data' is the data to be sent as the request body\n  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n  // Must be of one of the following types:\n  // 1. string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // 2. Browser only: FormData, File, Blob\n  // 3. Node only: Stream\n  data: { name: 'Mike' },\n\n  // 'headers' are custom headers to be sent\n  headers: { 'Content-Type': 'multipart/form-data' },\n\n  // 'timeout' specifies the number of milliseconds before the request times out.\n  // If the request takes longer than 'timeout', request will be aborted and throw RequestError.\n  timeout: 1000,\n\n  // ’prefix‘ used to set URL's prefix\n  // ( e.g. request('/user/save', { prefix: '/api/v1' }) => request('/api/v1/user/save') )\n  prefix: '',\n\n  // ’suffix‘ used to set URL's suffix\n  // ( e.g. request('/api/v1/user/save', { suffix: '.json'}) => request('/api/v1/user/save.json') )\n  suffix: '',\n\n  // 'credentials' indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n  // omit: Never send or receive cookies.\n  // same-origin: Send user credentials (cookies, basic http auth, etc..) if the URL is on the same origin as the calling script. This is the default value.\n  // include: Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls.\n  credentials: 'same-origin', // default\n\n  // ’useCache‘ The GET request would be cache in ttl milliseconds when 'useCache' is true.\n  // The cache key would be 'url + params + method'.\n  useCache: false, // default\n\n  // 'ttl' cache duration（milliseconds），0 is infinity\n  ttl: 60000,\n\n  // 'maxCache' are the max number of requests to be cached, 0 means infinity.\n  maxCache: 0,\n\n  // According to http protocal, request of GET used to get data from server, it's necessary to cache response data when server data update not frequently. We provide 'validateCache'\n  // for some cases that need to cache data with other method reqeust.\n  validateCache: (url, options) => { return options.method.toLowerCase() === 'get' },\n\n\n  // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object or array.\n  // 1. requestType === 'json' :(default )\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/json;charset=UTF-8',\n  //   ...options.headers,\n  // }\n  // options.body = JSON.stringify(data)\n  //\n  // 2. requestType === 'form':\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',\n  //   ...options.headers,\n  // };\n  // options.body = query-string.stringify(data);\n  //\n  // 3. other requestType\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   ...options.headers,\n  // };\n  // options.body = data;\n  requestType: 'json', // default\n\n  // 'parseResponse' whether processing response\n  parseResponse: true, // default\n\n  // 'charset' This parameter can be used when the server returns gbk to avoid garbled characters.(parseResponse should set to true)\n  charset: 'gbk',\n\n  // 'responseType': how to processing response.(parseResponse should be true)\n  // The default value is 'json', would processing response by Response.text().then( d => JSON.parse(d) )\n  // Other responseType (text, blob, arrayBuffer, formData), would processing response by Response[responseType]()\n  responseType: 'json', // default\n\n  // 'throwErrIfParseFail': whether throw error or not when JSON parse data fail and responseType is 'json'.\n  throwErrIfParseFail: false, // default\n\n  // 'getResponse': if you need the origin Response, set true and will return { data, response }.\n  getResponse: false,// default\n\n  // 'errorHandler' error handle entry.\n  errorHandler: function(error) { /* 异常处理 */ },\n\n  // 'cancelToken' the token of cancel request.\n  cancelToken: null,\n}\n```\n\n### Extend Options\n\nSometimes we need to update options after **extend** a request instance, umi-request provide **extendOptions** for users to update options:\n\n```javascript\nconst request = extend({ timeout: 1000, params: { a: '1' } });\n// default options is: { timeout: 1000, params: { a: '1' }}\n\nrequest.extendOptions({ timeout: 3000, params: { b: '2' } });\n// after extendOptions: { timeout: 3000, params: { a: '1', b: '2' }}\n```\n\n## Response Schema\n\nThe response for a request contains the following information.\n\n```javascript\n{\n  // 'data' is the response that was provided by the server\n  data: {},\n\n  // 'status' is the HTTP status code from the server response\n  status: 200,\n\n  // 'statusText' is the HTTP status message from the server response\n  statusText: 'OK',\n\n  // 'headers' the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n}\n```\n\nWhen options.getResponse === false, the response schema would be 'data'\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: false }).then(function(data) {\n  console.log(data);\n});\n```\n\nWhen options.getResponse === true ，the response schema would be { data, response }\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: true }).then(function({ data, response }) {\n  console.log(data);\n  console.log(response.status);\n  console.log(response.statusText);\n  console.log(response.headers);\n});\n```\n\nYou can get Response from `error` object in errorHandler or request.catch.\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n\nconst errorHandler = function(error) {\n  const codeMap = {\n    '021': 'An error has occurred',\n    '022': 'It’s a big mistake,',\n    // ....\n  };\n  if (error.response) {\n    // The request was made and the server responded with a status code\n    // that falls out of the range of 2xx\n    console.log(error.response.status);\n    console.log(error.response.headers);\n    console.log(error.data);\n    console.log(error.request);\n    console.log(codeMap[error.data.status]);\n  } else {\n    // The request was made but no response was received or error occurs when setting up the request.\n    console.log(error.message);\n  }\n\n  throw error; // If throw. The error will continue to be thrown.\n\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n  // return {some: 'data'};\n};\n\n// 1. Unified processing\nconst extendRequest = extend({ errorHandler });\n\n// 2. Separate special treatment\n// If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\nrequest('/api/v1/xxx', { errorHandler });\n\n// 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\nrequest('/api/v1/xxx')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    return errorHandler(error);\n  });\n```\n\n## Middleware\n\nExpressive HTTP middleware framework for node.js. For development to enhance before and after request. Support create instance, global, core middlewares.\n\n**Instance Middleware (default)** request.use(fn) Different instances's instance middleware are independence.\n**Global Middleware** request.use(fn, { global: true }) Different instances share global middlewares.\n**Core Middleware** request.use(fn, { core: true }) Used to expand request core.\n\nrequest.use(fn[, options])\n\n### params\n\nfn params\n\n- ctx(Object)：context, content request and response\n- next(Function)：function to call the next middleware\n\noptions params\n\n- global(boolean): whether global， higher priority than core\n- core(boolean): whether core\n\n### example\n\n1. same type of middlewares\n\n```javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n});\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n\n```shell\na1 -> b1 -> response -> b2 -> a2\n```\n\n2. Defferent type of middlewares\n\n```javascript\nrequest.use(async (ctx, next) => {\n  console.log('instanceA1');\n  await next();\n  console.log('instanceA2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('instanceB1');\n  await next();\n  console.log('instanceB2');\n});\nrequest.use(\n  async (ctx, next) => {\n    console.log('globalA1');\n    await next();\n    console.log('globalA2');\n  },\n  { global: true }\n);\nrequest.use(\n  async (ctx, next) => {\n    console.log('coreA1');\n    await next();\n    console.log('coreA2');\n  },\n  { core: true }\n);\n```\n\norder of middlewares be called:\n\n```shell\ninstanceA1 -> instanceB1 -> globalA1 -> coreA1 -> coreA2 -> globalA2 -> instanceB2 -> instanceA2\n```\n\n3. Enhance request\n\n```javascript\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n\n  if (url.indexOf('/api') !== 0) {\n    ctx.req.url = `/api/v1/${url}`;\n  }\n  ctx.req.options = {\n    ...options,\n    foo: 'foo',\n  };\n\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // ...\n  }\n});\n```\n\n4. Use core middleware to expand request core.\n\n```javascript\nrequest.use(\n  async (ctx, next) => {\n    const { req } = ctx;\n    const { url, options } = req;\n    const { __umiRequestCoreType__ = 'normal' } = options;\n\n    // __umiRequestCoreType__ use to identificat request core\n    // when value is 'normal' , use umi-request 's fetch request core\n    if (__umiRequestCoreType__ === 'normal') {\n      await next();\n      return;\n    }\n\n    // when value is not normal, use your request func.\n    const response = getResponseByOtherWay();\n\n    ctx.res = response;\n\n    await next();\n    return;\n  },\n  { core: true }\n);\n\nrequest('/api/v1/rpc', {\n  __umiRequestCoreType__: 'rpc',\n  parseResponse: false,\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Interceptor\n\nYou can intercept requests or responses before they are handled by then or catch.\n\n1. global Interceptor\n\n```javascript\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return {\n    url: `${url}&interceptors=yes`,\n    options: { ...options, interceptors: true },\n  };\n});\n\n// Same as the last one\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: true }\n);\n\n// response interceptor, chagne response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n// handling error in response interceptor\nrequest.interceptors.response.use(response => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n// clone response in response interceptor\nrequest.interceptors.response.use(async response => {\n  const data = await response.clone().json();\n  if (data && data.NOT_LOGIN) {\n    location.href = '登录url';\n  }\n  return response;\n});\n```\n\n1. instance Interceptor\n\n```javascript\n// Global interceptors are used `request` instance method directly\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: false }\n); // second paramet defaults { global: true }\n\nfunction createClient(baseUrl) {\n  const request = extend({\n    prefix: baseUrl,\n  });\n  return request;\n}\n\nconst clientA = createClient('/api');\nconst clientB = createClient('/api');\n// Independent instance Interceptor\nclientA.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientA`,\n      options,\n    };\n  },\n  { global: false }\n);\n\nclientB.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientB`,\n      options,\n    };\n  },\n  { global: false }\n);\n```\n\n## Cancel request\n\n### Use AbortController\n\nBase on [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) that allows you to abort one or more Web requests as and when desired.\n\n```javascript\nimport Request, { AbortController } from 'umi-request';\n\nconst controller = new AbortController(); // create a controller\nconst { signal } = controller; // grab a reference to its associated AbortSignal object using the AbortController.signal property\n\nsignal.addEventListener('abort', () => {\n  console.log('aborted!');\n});\n\nRequest('/api/response_after_1_sec', {\n  signal, // pass in the AbortSignal as an option inside the request's options object (see {signal}, below). This associates the signal and controller with the fetch request and allows us to abort it by calling AbortController.abort(),\n});\n\n// 取消请求\nsetTimeout(() => {\n  controller.abort(); // Aborts a DOM request before it has completed. This is able to abort fetch requests, consumption of any response Body, and streams.\n}, 100);\n```\n\n### Use Cancel Token\n\n> Cancel Token still work, but we don’t recommend using them in the new code.\n\n1. You can cancel a request using a cancel token.\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n\nRequest.get('/api/cancel', {\n  cancelToken: token,\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post(\n  '/api/cancel',\n  {\n    name: 'hello world',\n  },\n  {\n    cancelToken: token,\n  }\n);\n\n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n\nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  }),\n});\n\n// cancel request\ncancel();\n```\n\n## Cases\n\n### How to get Response Headers\n\nUse **Headers.get()** (more detail see [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n\n```javascript\nrequest('/api/v1/some/api', { getResponse: true }).then(({ data, response }) => {\n  response.headers.get('Content-Type');\n});\n```\n\nIf want to get a custem header, you need to set [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) on server.\n\n### File upload\n\nUse FormData() contructor，the browser will add rerequest header `\"Content-Type: multipart/form-data\"` automatically, developer don't need to add request header **Content-Type**\n\n```javascript\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method: 'post', data: formData });\n```\n\nThe Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.[Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"60917c1024cff2d2d926f019b573273e47b54160","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.2-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-m5lB7sPcA7PMSH5AWAe4Y9bISiqt7DTCD7CN5Sg07KU7Ax9YM2KGEWWN+eSASTpAD/1HiwGnUK8hYLPw+E90RA==","shasum":"8b9cabe4db511e046475eae95a1e151ff2e5c188","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.2-beta.0.tgz","fileCount":6,"unpackedSize":165150,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJey2w8CRA9TVsSAnZWagAAaN0P/jsJ8dqBwpWvAMMJeSeY\nUko3PXXgk/2phfUOA7iOdsGDC8+ZpX6TOH00xgnQIol20Zwjq4k+MKQia+Or\nNzl+CS0xh7y4Ot5ZVyutRpiWX/bTiXPO9lDiVXJT/e8H9Vscifp13HQEopFL\nRze+4WAfwbabeXpVWNwAJTALOCeVcNmTUEY62l5wxEz/3PRXdgwJOoMPVLg3\nZWgxqUGRs97r/ubwV6RN9g+Uc+4Oshs5Vca79lslbfCvY2UHnk77OHsON2BO\ngFS4RHAFgh0+jTYqd8jU3ce3fg6d5DAjS9BfXa7XTGpqvPe8/hO06PvteUk7\na7fhAuY5+F/cY1YH/WdYhcOqYFzOqdEFkxcLUwL8dbqQd8FlItRqQ2YYi1D8\nLubuzSSBz/l4LmWvUyFVcJYr0Svxa5dJodbCnOJ5ngdmuNJ/ZRs4Euaffy4l\nBn/dJ0ffIaCl9e2Jsw9Xmi+QWf7/9F3P8V6gjUuHxc6trYO0IiH5z1DUGc/6\nJK8sGU0WMyIZmu4s8XpfGHOfbZMNfRA7h8oxSHFMGQ6nk0/9CVFfVQd7jhqi\nW0F0lfv11DjMDR+doWbWL05ocdxkpkhIQxIXu/lE5dGvgBnM7JVEOxhEpzV4\n8YNDOAzL/XYmKEmAhQ41grjm0YwVBY6yvO8p4/fu842db06/geD9ggRSaxRY\n5cFc\r\n=8VCo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB7ism3wjOEBTLSze+VMz9BiNSv3wLiFp8wzLG8vuhdLAiEAu5rMK4/nufjGz06y/V7b3udFgNuvP4BEIlF96NOXp5U="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.2-beta.0_1590389819923_0.8910706176739471"},"_hasShrinkwrap":false},"1.3.2":{"name":"umi-request","version":"1.3.2","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"0232e30484da7d56db1695941764bd2444e1d8ba","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.2","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-9RSZXX2psu6YDN3pFH+Jn/sYA2c0hWZl6RBKr8ndi0iLsrKaMaGSJ6qvsXt648lwDtxVQHyccADVyN31kZ/vmA==","shasum":"c42a8991ee143b1828291c157ce63107633ea450","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.2.tgz","fileCount":6,"unpackedSize":165182,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJey3LjCRA9TVsSAnZWagAATD8P+wYgo0JWo8TvoHPrG/Bx\nmHiQuBavG7W4H4w856Iq1TY8tuHd25OypVLT4ESjlfZJ04tFAed5edqgmW9v\n6bA0e0a6toPFPtJjUfI25XFCs4tbQR3noFDNzRaCBYPpO3G4PnuFHPbDYSwq\n8cMNwKlPRHNKaOYkpL/CEJ1QhudqZ5UXeEtexZZW/IRXLwpC5W67mZmjFFz1\nC7VS3050w83FYYCxrr2MTsiaHnPY1LGRp+hYVVCNJtYLw1PzbK6DZiLB7goM\nqS4pIfjCSrF4069qyUxZ/I8nijtfoSzR+lzhAY6GUGZspYDZKtDZyMZ37lz7\nrrryP/YbgdpIqbyNL3FnAZ7y/sywvc4E3m9VsY94iGVk3YAmPEaSYPPUf3mQ\n/QE25yL3zDtGyekopXoDftl/TaKhXRUhfwhZ4N/sTp8NNsUjglCP2tGF6TYl\n6fEwzcK9EL5rj3mFhKxli3LNl0/xUk0OcnrBvyMekSGDj6+6S6KOHLgMzlwE\njGL/TJ3tJthKqiXMgpOQtpWza4C8JN9BGZh3vJc9WCtoteh3yrJGCxLRfnU9\nCUJ480bEfB0EVdpwB6PpMbH482faT9eycss/Ui1JfeY5Pqs4JUFkY3EPms+Z\nRZMAqTtauvbxCGLHtgmq6eF/qgI8SH2KuNo14mReuWIjgGDOYwu8Mls3+dVx\ndnl2\r\n=Jdvr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCPJvq0BJXgfML+HstOzh3/+rDFzVST+SMvVuzMBwtd8wIgNf1aCkpv7I8VgcI0SXKSAt5DzeuaXT0RNZRlnQWmvGg="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.2_1590391523189_0.3111750045786803"},"_hasShrinkwrap":false},"1.3.3":{"name":"umi-request","version":"1.3.3","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"d9eb1299163a2c80d8bb448a72809e66c4fd4348","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.3","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-TRf5x11OJ/9VBi2ZzCJGg/ZFs6KXxpZg1hV0/9oYa9d4YZtQ62Gk6djbonYoMFkyw7fMcxRh8ayPe4YG/gCNeg==","shasum":"9f053a3bbf7c8e89765ca8e3c0118f1cb8481f11","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.3.tgz","fileCount":6,"unpackedSize":103332,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezgfsCRA9TVsSAnZWagAATEsP/iE6IqZhElcsDAHTrXqb\nNIuX0HZq3k0ixjodw3BMJU9ayoVMH5sH0QAjseaknqQ2nFDRkIApsiEr/g6B\nULCMgOSCZp/fDXw0ZxkJnyB3s5iBDJXfbdrZihik9OiXlGJBm4kVjzX5vusM\naKdD+HbjvWvxsKjgJlkbZhL7yqODlX3FrccxUoBmyKQcJiQRfaqY1bGge9/u\n2APBlAV73O+H3i2rDGC1WbsblX1qooph2XTb30rF12yt64mf06q8zeRr5P+Y\nvbeMvrTxiWmIvr2qoziaRoL1gW2j6aVtSJOWb1CmrFGW0gPWl4BrZr/uFWHp\nCj0sl/qcfrT2kxDyWNMZIrzvR8U4GyLlCIWzpqL1/5pLgh1GPSKwQO0YSC9j\nC00huDQx6Ko1HXiqR5y1BFZ/Jt7vTo+uKOn01AqoLpVhacCvPly7cHQnZ61Z\no+k2qi6V666WqQFe17fogD+ZJinvzfpKfkrp5BR0DEIsLEScp9Ku/UWp8BLa\nCXCBXaHps/u2JxHMzE2tyjWWafL44temDEvBqqTrIjiYnbzyxjIz+1qHTLNh\nNnRgITwEfomXEIsrbYUPuA28fJ5xLFbYWnxSbpsnphuJBYf6864zl5Ohb5qT\n3L+gI5g8huiBvh0/84coG4k2OA8UFneRe2octUU9s3u4ZjY/3fwrqzm1XG24\n4Me5\r\n=lAOe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAVUIFMq3F10YsEhy0aAD4SSmCQbLxmOuEJ4danBKMduAiB0jjuQnDNdPrAOfRxAS+dB1RIClueD4c+RKUzrXraYww=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.3_1590560747808_0.9938687304718756"},"_hasShrinkwrap":false},"1.3.4-beta.0":{"name":"umi-request","version":"1.3.4-beta.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","abortcontroller-polyfill":"^1.4.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n---\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features             | umi-request            | fetch                  | axios          |\n| :------------------- | :--------------------- | :--------------------- | :------------- |\n| implementation       | Browser native support | Browser native support | XMLHttpRequest |\n| size                 | 9k                     | 4k (polyfill)          | 14k            |\n| query simplification | ✅                     | ❌                     | ✅             |\n| post simplification  | ✅                     | ❌                     | ❌             |\n| timeout              | ✅                     | ❌                     | ✅             |\n| cache                | ✅                     | ❌                     | ❌             |\n| error Check          | ✅                     | ❌                     | ❌             |\n| error Handling       | ✅                     | ❌                     | ✅             |\n| interceptor          | ✅                     | ❌                     | ✅             |\n| prefix               | ✅                     | ❌                     | ❌             |\n| suffix               | ✅                     | ❌                     | ❌             |\n| processing gbk       | ✅                     | ❌                     | ❌             |\n| middleware           | ✅                     | ❌                     | ❌             |\n| cancel request       | ✅                     | ❌                     | ✅             |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n```\nnpm install --save umi-request\n```\n\n## Example\n\nPerforming a `GET` request\n\n```javascript\nimport request from 'umi-request';\n\nrequest\n  .get('/api/v1/xxx?id=1')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\n// use options.params\nrequest\n  .get('/api/v1/xxx', {\n    params: {\n      id: 1,\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nPerforming a `POST` request\n\n```javascript\nrequest\n  .post('/api/v1/user', {\n    data: {\n      name: 'Mike',\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## umi-request API\n\nRequests can be made by passing relevant options to `umi-request`\n\n**umi-request(url[, options])**\n\n```javascript\nimport request from 'umi-request';\n\nrequest('/api/v1/xxx', {\n  method: 'get',\n  params: { id: 1 },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\nrequest('/api/v1/user', {\n  method: 'post',\n  data: {\n    name: 'Mike',\n  },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Request method aliases\n\nFor convenience umi-request have been provided for all supported methods.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\n## Creating an instance\n\nYou can use `extend({[options]})` to create a new instance of umi-request.\n\n**extend([options])**\n\n```javascript\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  prefix: '/api/v1',\n  timeout: 1000,\n  headers: {\n    'Content-Type': 'multipart/form-data',\n  },\n});\n\nrequest\n  .get('/user')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nCreate an instance of umi-request in NodeJS enviroment\n\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 });\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\nThe available instance methods are list below. The specified options will be merge with the instance options.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\nMore umi-request cases can see [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n## request options\n\n| Parameter           | Description                                                      | Type                      | Optional Value                    | Default                    |\n| :------------------ | :--------------------------------------------------------------- | :------------------------ | :-------------------------------- | :------------------------- |\n| method              | request method                                                   | string                    | get , post , put ...              | get                        |\n| params              | url request parameters                                           | object or URLSearchParams | --                                | --                         |\n| data                | Submitted data                                                   | any                       | --                                | --                         |\n| headers             | fetch original parameters                                        | object                    | --                                | {}                         |\n| timeout             | timeout, default millisecond, write with caution                 | number                    | --                                | --                         |\n| prefix              | prefix, generally used to override the uniform settings prefix   | string                    | --                                | --                         |\n| suffix              | suffix, such as some scenes api need to be unified .json         | string                    | --                                |\n| credentials         | fetch request with cookies                                       | string                    | --                                | credentials: 'same-origin' |\n| useCache            | Whether to use caching (only support browser environment)        | boolean                   | --                                | false                      |\n| validateCache       | cache strategy function                                          | (url, options) => boolean | --                                | only get request to cache  |\n| ttl                 | Cache duration, 0 is not expired                                 | number                    | --                                | 60000                      |\n| maxCache            | Maximum number of caches                                         | number                    | --                                | 0(Infinity)                |\n| requestType         | post request data type                                           | string                    | json , form                       | json                       |\n| parseResponse       | response processing simplification                               | boolean                   | --                                | true                       |\n| charset             | character set                                                    | string                    | utf8 , gbk                        | utf8                       |\n| responseType        | How to parse the returned data                                   | string                    | json , text , blob , formData ... | json , text                |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json'      | boolean                   | --                                | false                      |\n| getResponse         | Whether to get the source response, the result will wrap a layer | boolean                   | --                                | fasle                      |\n| errorHandler        | exception handling, or override unified exception handling       | function(error)           | --                                |\n| cancelToken         | Token to cancel request                                          | CancelToken.token         | --                                | --                         |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description            | Type   | Optional Value       | Default |\n| :-------- | :--------------------- | :----- | :------------------- | :------ |\n| method    | request method         | string | get , post , put ... | get     |\n| params    | url request parameters | object | --                   | --      |\n| data      | Submitted data         | any    | --                   | --      |\n| ...       |\n\n```javascript\n{\n  // 'method' is the request method to be used when making the request\n  method: 'get', // default\n\n  // 'params' are the URL parameters to be sent with request\n  // Must be a plain object or a URLSearchParams object\n  params: { id: 1 },\n\n  // 'paramSerializer' is a function in charge of serializing 'params'. ( be aware of 'params' was merged by extends's 'params' and request's 'params' and URLSearchParams will be transform to plain object. )\n  paramsSerializer: function (params) {\n    return Qs.stringify(params, { arrayFormat: 'brackets' })\n  },\n\n  // 'data' 作为请求主体被发送的数据\n  // 适用于这些请求方法 'PUT', 'POST', 和 'PATCH'\n  // 必须是以下类型之一：\n  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // - 浏览器专属：FormData, File, Blob\n  // - Node 专属： Stream\n\n  // 'data' is the data to be sent as the request body\n  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n  // Must be of one of the following types:\n  // 1. string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // 2. Browser only: FormData, File, Blob\n  // 3. Node only: Stream\n  data: { name: 'Mike' },\n\n  // 'headers' are custom headers to be sent\n  headers: { 'Content-Type': 'multipart/form-data' },\n\n  // 'timeout' specifies the number of milliseconds before the request times out.\n  // If the request takes longer than 'timeout', request will be aborted and throw RequestError.\n  timeout: 1000,\n\n  // ’prefix‘ used to set URL's prefix\n  // ( e.g. request('/user/save', { prefix: '/api/v1' }) => request('/api/v1/user/save') )\n  prefix: '',\n\n  // ’suffix‘ used to set URL's suffix\n  // ( e.g. request('/api/v1/user/save', { suffix: '.json'}) => request('/api/v1/user/save.json') )\n  suffix: '',\n\n  // 'credentials' indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n  // omit: Never send or receive cookies.\n  // same-origin: Send user credentials (cookies, basic http auth, etc..) if the URL is on the same origin as the calling script. This is the default value.\n  // include: Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls.\n  credentials: 'same-origin', // default\n\n  // ’useCache‘ The GET request would be cache in ttl milliseconds when 'useCache' is true.\n  // The cache key would be 'url + params + method'.\n  useCache: false, // default\n\n  // 'ttl' cache duration（milliseconds），0 is infinity\n  ttl: 60000,\n\n  // 'maxCache' are the max number of requests to be cached, 0 means infinity.\n  maxCache: 0,\n\n  // According to http protocal, request of GET used to get data from server, it's necessary to cache response data when server data update not frequently. We provide 'validateCache'\n  // for some cases that need to cache data with other method reqeust.\n  validateCache: (url, options) => { return options.method.toLowerCase() === 'get' },\n\n\n  // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object or array.\n  // 1. requestType === 'json' :(default )\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/json;charset=UTF-8',\n  //   ...options.headers,\n  // }\n  // options.body = JSON.stringify(data)\n  //\n  // 2. requestType === 'form':\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',\n  //   ...options.headers,\n  // };\n  // options.body = query-string.stringify(data);\n  //\n  // 3. other requestType\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   ...options.headers,\n  // };\n  // options.body = data;\n  requestType: 'json', // default\n\n  // 'parseResponse' whether processing response\n  parseResponse: true, // default\n\n  // 'charset' This parameter can be used when the server returns gbk to avoid garbled characters.(parseResponse should set to true)\n  charset: 'gbk',\n\n  // 'responseType': how to processing response.(parseResponse should be true)\n  // The default value is 'json', would processing response by Response.text().then( d => JSON.parse(d) )\n  // Other responseType (text, blob, arrayBuffer, formData), would processing response by Response[responseType]()\n  responseType: 'json', // default\n\n  // 'throwErrIfParseFail': whether throw error or not when JSON parse data fail and responseType is 'json'.\n  throwErrIfParseFail: false, // default\n\n  // 'getResponse': if you need the origin Response, set true and will return { data, response }.\n  getResponse: false,// default\n\n  // 'errorHandler' error handle entry.\n  errorHandler: function(error) { /* 异常处理 */ },\n\n  // 'cancelToken' the token of cancel request.\n  cancelToken: null,\n}\n```\n\n### Extend Options\n\nSometimes we need to update options after **extend** a request instance, umi-request provide **extendOptions** for users to update options:\n\n```javascript\nconst request = extend({ timeout: 1000, params: { a: '1' } });\n// default options is: { timeout: 1000, params: { a: '1' }}\n\nrequest.extendOptions({ timeout: 3000, params: { b: '2' } });\n// after extendOptions: { timeout: 3000, params: { a: '1', b: '2' }}\n```\n\n## Response Schema\n\nThe response for a request contains the following information.\n\n```javascript\n{\n  // 'data' is the response that was provided by the server\n  data: {},\n\n  // 'status' is the HTTP status code from the server response\n  status: 200,\n\n  // 'statusText' is the HTTP status message from the server response\n  statusText: 'OK',\n\n  // 'headers' the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n}\n```\n\nWhen options.getResponse === false, the response schema would be 'data'\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: false }).then(function(data) {\n  console.log(data);\n});\n```\n\nWhen options.getResponse === true ，the response schema would be { data, response }\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: true }).then(function({ data, response }) {\n  console.log(data);\n  console.log(response.status);\n  console.log(response.statusText);\n  console.log(response.headers);\n});\n```\n\nYou can get Response from `error` object in errorHandler or request.catch.\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n\nconst errorHandler = function(error) {\n  const codeMap = {\n    '021': 'An error has occurred',\n    '022': 'It’s a big mistake,',\n    // ....\n  };\n  if (error.response) {\n    // The request was made and the server responded with a status code\n    // that falls out of the range of 2xx\n    console.log(error.response.status);\n    console.log(error.response.headers);\n    console.log(error.data);\n    console.log(error.request);\n    console.log(codeMap[error.data.status]);\n  } else {\n    // The request was made but no response was received or error occurs when setting up the request.\n    console.log(error.message);\n  }\n\n  throw error; // If throw. The error will continue to be thrown.\n\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n  // return {some: 'data'};\n};\n\n// 1. Unified processing\nconst extendRequest = extend({ errorHandler });\n\n// 2. Separate special treatment\n// If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\nrequest('/api/v1/xxx', { errorHandler });\n\n// 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\nrequest('/api/v1/xxx')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    return errorHandler(error);\n  });\n```\n\n## Middleware\n\nExpressive HTTP middleware framework for node.js. For development to enhance before and after request. Support create instance, global, core middlewares.\n\n**Instance Middleware (default)** request.use(fn) Different instances's instance middleware are independence.\n**Global Middleware** request.use(fn, { global: true }) Different instances share global middlewares.\n**Core Middleware** request.use(fn, { core: true }) Used to expand request core.\n\nrequest.use(fn[, options])\n\n### params\n\nfn params\n\n- ctx(Object)：context, content request and response\n- next(Function)：function to call the next middleware\n\noptions params\n\n- global(boolean): whether global， higher priority than core\n- core(boolean): whether core\n\n### example\n\n1. same type of middlewares\n\n```javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n});\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n\n```shell\na1 -> b1 -> response -> b2 -> a2\n```\n\n2. Defferent type of middlewares\n\n```javascript\nrequest.use(async (ctx, next) => {\n  console.log('instanceA1');\n  await next();\n  console.log('instanceA2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('instanceB1');\n  await next();\n  console.log('instanceB2');\n});\nrequest.use(\n  async (ctx, next) => {\n    console.log('globalA1');\n    await next();\n    console.log('globalA2');\n  },\n  { global: true }\n);\nrequest.use(\n  async (ctx, next) => {\n    console.log('coreA1');\n    await next();\n    console.log('coreA2');\n  },\n  { core: true }\n);\n```\n\norder of middlewares be called:\n\n```shell\ninstanceA1 -> instanceB1 -> globalA1 -> coreA1 -> coreA2 -> globalA2 -> instanceB2 -> instanceA2\n```\n\n3. Enhance request\n\n```javascript\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n\n  if (url.indexOf('/api') !== 0) {\n    ctx.req.url = `/api/v1/${url}`;\n  }\n  ctx.req.options = {\n    ...options,\n    foo: 'foo',\n  };\n\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // ...\n  }\n});\n```\n\n4. Use core middleware to expand request core.\n\n```javascript\nrequest.use(\n  async (ctx, next) => {\n    const { req } = ctx;\n    const { url, options } = req;\n    const { __umiRequestCoreType__ = 'normal' } = options;\n\n    // __umiRequestCoreType__ use to identificat request core\n    // when value is 'normal' , use umi-request 's fetch request core\n    if (__umiRequestCoreType__ === 'normal') {\n      await next();\n      return;\n    }\n\n    // when value is not normal, use your request func.\n    const response = getResponseByOtherWay();\n\n    ctx.res = response;\n\n    await next();\n    return;\n  },\n  { core: true }\n);\n\nrequest('/api/v1/rpc', {\n  __umiRequestCoreType__: 'rpc',\n  parseResponse: false,\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Interceptor\n\nYou can intercept requests or responses before they are handled by then or catch.\n\n1. global Interceptor\n\n```javascript\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return {\n    url: `${url}&interceptors=yes`,\n    options: { ...options, interceptors: true },\n  };\n});\n\n// Same as the last one\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: true }\n);\n\n// response interceptor, chagne response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n// handling error in response interceptor\nrequest.interceptors.response.use(response => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n// clone response in response interceptor\nrequest.interceptors.response.use(async response => {\n  const data = await response.clone().json();\n  if (data && data.NOT_LOGIN) {\n    location.href = '登录url';\n  }\n  return response;\n});\n```\n\n1. instance Interceptor\n\n```javascript\n// Global interceptors are used `request` instance method directly\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: false }\n); // second paramet defaults { global: true }\n\nfunction createClient(baseUrl) {\n  const request = extend({\n    prefix: baseUrl,\n  });\n  return request;\n}\n\nconst clientA = createClient('/api');\nconst clientB = createClient('/api');\n// Independent instance Interceptor\nclientA.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientA`,\n      options,\n    };\n  },\n  { global: false }\n);\n\nclientB.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientB`,\n      options,\n    };\n  },\n  { global: false }\n);\n```\n\n## Cancel request\n\n### Use AbortController\n\nBase on [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) that allows you to abort one or more Web requests as and when desired.\n\n```javascript\nimport Request, { AbortController } from 'umi-request';\n\nconst controller = new AbortController(); // create a controller\nconst { signal } = controller; // grab a reference to its associated AbortSignal object using the AbortController.signal property\n\nsignal.addEventListener('abort', () => {\n  console.log('aborted!');\n});\n\nRequest('/api/response_after_1_sec', {\n  signal, // pass in the AbortSignal as an option inside the request's options object (see {signal}, below). This associates the signal and controller with the fetch request and allows us to abort it by calling AbortController.abort(),\n});\n\n// 取消请求\nsetTimeout(() => {\n  controller.abort(); // Aborts a DOM request before it has completed. This is able to abort fetch requests, consumption of any response Body, and streams.\n}, 100);\n```\n\n### Use Cancel Token\n\n> Cancel Token still work, but we don’t recommend using them in the new code.\n\n1. You can cancel a request using a cancel token.\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n\nRequest.get('/api/cancel', {\n  cancelToken: token,\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post(\n  '/api/cancel',\n  {\n    name: 'hello world',\n  },\n  {\n    cancelToken: token,\n  }\n);\n\n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n\nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  }),\n});\n\n// cancel request\ncancel();\n```\n\n## Cases\n\n### How to get Response Headers\n\nUse **Headers.get()** (more detail see [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n\n```javascript\nrequest('/api/v1/some/api', { getResponse: true }).then(({ data, response }) => {\n  response.headers.get('Content-Type');\n});\n```\n\nIf want to get a custem header, you need to set [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) on server.\n\n### File upload\n\nUse FormData() contructor，the browser will add rerequest header `\"Content-Type: multipart/form-data\"` automatically, developer don't need to add request header **Content-Type**\n\n```javascript\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method: 'post', data: formData });\n```\n\nThe Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.[Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md","gitHead":"03611dea1c5bec2fe3053e5372c45f479cc30db7","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.4-beta.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-n+I/QKupwgQXbh8aJs8JADhdYrTL65WwWM7lReLArUucx1/WQuU9rzxL4sq2vYegtwzjwTYNXaY9aY37x6cajw==","shasum":"a29f15183df393a967e44d29d877f8ac5e283b17","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.4-beta.0.tgz","fileCount":6,"unpackedSize":140330,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeziNDCRA9TVsSAnZWagAAkA4P/2s7aPLVGQjjKnbZNeey\npf7h2EfWkwe7+cChDCYyBxzrlNOMfoKmRkH2+nJ7x7qgtH4sl853ysKJv3/I\nuuMzBeibwbFYjRr5CM36W03oVHu3DYPk93jeluxlZ2V/M5MTqaJCX0wHXFl/\nxuIMVw3qh1ffV8nJQaNaJNLd7VSr87pdZFjjb4FnSGn1ghXY3Otbo+uUhMk/\nKhLOCdDsz5gG2iqT3YHUH7w2ykkOZwtHfU6lAEHBsYk4rtlugXHEYvoajt/Y\nDiNbbnQDoguB/6JCdFmYVYdoNkCtW/3vlXrCxWg2EKSqU1EeMtXtuEtjdG6G\nsNEyH7zEDpfEp0/MpPaNZd3QCyDVIiROhyv5vofl/BSb5XT4s0DEGIqG3atH\nBek2ufelpDlDDU9k86x2BHNIhK2+zCgYreN+4xO6S2HZlEUwUib7OBqrhPd2\nkKhR0+RisQsBkDfnU1XReWqEb239bf66eI0LovGlZZuJs5veVJaiL6Pu2w5a\nwC5kUd3BiRxRAnO60wDOpnjWXfTKaXUqEmlRx+J4Ilfnp6jiLQ9R+4EPgoMT\nXl6XwhK/+oJL2EFF0qNRtPUFEfhpoaMB50lFJtq6pg2KcL8Mi+AJCwEUthtq\nBr2lZWEGao4egbG5ScRcAZWeVAf8pZttPPAeamFTHBz+I8e5gMxzWDgeMS8T\nFdwR\r\n=ReFf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCthdqftXDFsfeKa/2Y7zpUm6ehUU06wImCBpkGlvoLYgIhANxfWvFmYUZfEsADk2vLQ/f4dLRfk0k1YdPoFaZMnkz3"}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.4-beta.0_1590567746871_0.4470769648773778"},"_hasShrinkwrap":false},"1.3.4":{"name":"umi-request","version":"1.3.4","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"eaca25ea07d6a9a13e6a9d310061dd4bdc28c4ec","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.4","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-sY33Mjo+COJpjDDRmbmn1jXBTq1uo+1rrZtcrsyasZB6VEnmGEL3x4mkko9lzKyp4jLGaK4n67iRJTa3SFaRfQ==","shasum":"dcab7287ac3a192a853d8d752dede861b27de6b9","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.4.tgz","fileCount":6,"unpackedSize":165182,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6YSOCRA9TVsSAnZWagAAUFsQAJBU8A60H4PKlNlY9QrP\nCbqjGrekeiimfTj1kF5QikEDxgef92omGIIJIFZ1eovxvlR0XQDkFJvEvQwZ\nafr/R9jxWbSskoZPjn8GCZT7XYbR9TH5pvavvOXck084RPBGM5wOA3M/LYXb\nshN6GacxtnRDPZB5QaVf+9CcZDZfmEQcGWgjAfwDeRSPkdWgAxFm29ZkFr1V\nUhJSrxnnOmpBDqzFpp3Czw5fMyctFKehxAPQgfdLC+fUTHlkZKRBka9PwAcM\nFnneJSE83QL6rOqxFl5wy2twLapBAFEWfOiRMbjVWJYzoTqyOPVF5UFByX8F\n1541bKXHQl0alp7z+0/GoObDe8mtjIsXbuhXCCLl0BU67YVFfNNLETSqad8w\n5Mm3oBmFyYXcsPK7fKcnnMis2sbC18xHHleCWk3HAbvt8wGthXVQYBDM+swB\nG4qfkW0ZCuagjPQv94MNWOsWOglCdC5KDnY0+wZ1uOVNTpFWZW9iIyB8Hu7m\nLGRFUcO91iWPDT0SMOwvPv9dL5KzfQtmmBUYjwSY+yuNOF7Z2TsdWlP0e0RU\nwCjW6s5Hads/aBj3xyCBQ3bSb7oTTmIQ2e33Lq3YSUz9d3j+BosTWqf/2Cc4\nim7PUsJdTgnPmhyHlqjF4FLqwNgxvmve38saV6kmX3uBt3qPvT73UUF38/pW\nf55s\r\n=J2U5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICx7GXotHXJrO/Wt5YS3auHnOnNe4qK+2DJqk/BwlVM4AiBEFxZbPC7AqDO58Evz/kXY4m7rd7xs98jdX+li57c5Kg=="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.4_1592362125570_0.07672863215273673"},"_hasShrinkwrap":false},"1.3.5":{"name":"umi-request","version":"1.3.5","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"d9eb1299163a2c80d8bb448a72809e66c4fd4348","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.5","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-PqGz1mbLTkLjvL7ovM5Tmx/ChfY819T6P6VIsp4n15Lldn9Q85VYil4WuHSPpnur7I0thbWBuMnfLY7j5QWstg==","shasum":"2af7e9fbaaeed0086c07d8c4876b3af65c084aea","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.5.tgz","fileCount":6,"unpackedSize":103332,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6YjFCRA9TVsSAnZWagAAHaIP/39wgP7lVwYOa+fidWAy\nOQEGVrDwvmpJNmVXfF9hdwhxNhl/tejoN1NAoP9Yer1h4hN5am5CvEmTfKLh\nsK6J/GJnEQKONr/98gIPKEkHFIEnDENq0TBMYQJPy+g7O6XNHhtaMmZVB2HT\nvCO90Q80u3+rlGMUzx1Q48AEFsCY3K/3/877h8q5DB9SgDFtqn+Ms3v1KmLz\nbxjxGgRX3g+92HQ1ALKm4LuRUyKhQAMdcExnnoIWOANxn7ttLeofvaEEL6TW\nFuE996X6mifuwlLjmImIzQIoIkTT7+D/XKuBQU9CkT8W81xMTPiEotJ6MvYO\nM4qGAdGoggvoz5aMSdVlo+Wa9TExdXFZ5GKnyBxxsHon2/ZdDS5252HR1qAr\n8dKQGsqmWgvXlgnLuZXB7Oq3s75kqelBSzsLuDkKpEHqMUDv70fz184WxdJV\nFXAbI1DKf1MbM/ORotD5kDllZ/+qda//RHZK+yfR1bYITglHJiIM2Gna/+WH\nCVX6v4EbUcCPbaC9fvt5tn4e7Ex2J4ITOozvGMqElG13zsrL29wd59tXFEha\nZjNTdJVGdaBnJbNLqi8/C/UYk5jDnncuSGeBewMdCaCvWnv2IfxQz/mpW9Af\nj9Ci0fG2iJzG9yU7jIGifuW6+Zl7kXEpqk/EjwnfCusSuopE4fpze8PKSfxV\nykCB\r\n=eHKb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC944HVkYFI9JfYmszaAxRL8tYPYtjS5enISf7E1N78RwIgYtYNmo41k2yjWd1Vtx12z85OeMwdIaKC2DSEU6kYI3g="}]},"maintainers":[{"email":"clock157@163.com","name":"clock157"},{"email":"chenjsh36@gmail.com","name":"litou.cjs"},{"email":"sorrycc@gmail.com","name":"sorrycc"},{"email":"448627663@qq.com","name":"xiaohuoni"},{"email":"yutingzhao1991@sina.com","name":"yutingzhao1991"},{"email":"zinkey@vip.qq.com","name":"zinkey"}],"_npmUser":{"name":"litou.cjs","email":"chenjsh36@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.5_1592363204660_0.006128658857570191"},"_hasShrinkwrap":false},"1.3.6":{"name":"umi-request","version":"1.3.6","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"umi lib build --w","build":"umi lib build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"61bed5423bbd19897c24e6fe7eb9ae19c00da62c","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.6","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-qfz9RmKZhe/1dhABXI/b5AqA6KGToVxNgoAl6vyWZmhP74AXlWrGiw5id7ajjXGbMi/5q3XkeKl9Y2PvgE795Q==","shasum":"4d59aa23db828abb41074a2f0828150c4a1524d1","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.6.tgz","fileCount":6,"unpackedSize":166802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpi1iCRA9TVsSAnZWagAA1OEP/2YRa6CPSulW7vb399D6\n9t22a6JrqojWeJFNiUHhzEXlJVkzVcoYyXoZO/P0QRpZL4vWeaUYakpeZEs9\nLovXgrsRcj/03XxSASuBNPRp6Jesaqd2AupjpbyCxwq1wc1jLGSkFaU5yg9q\n9xsAO7T5gBJHNDSbcialIG+qjuFDK4rPJr6zdyDw/NHXags1hnLH1DEjA0M+\nbj7YfV4B5VrzV0bflBwyZhhjiGdUXz3h2utOdw9w+J48vWhvlYTbYAOo5sCA\nbO1/HrCxm5L70yGyhlHgzLOECbHmhMrbUw8iaWvsDVz4hFXgwCvKPz1vU5ht\nn9BXs8pYTU4z2EvBVt9BeVhKgwvdg3R5ecZRGlnf2aXyX82aY2HaI7JYa5ab\ngHHcisFe7TUOh2WtH84UhWfQ7cn5YqybrH0MJMvDz0qE+PJU38TSGJIiSY71\nzdYDVPcqLEBq1suKDWVmr6eN6KqCC6DxNA4573X/RJrqFsGOCY5n+/I2kJoP\nle9ID4vQmNYw8cDfEzOVs5LykDPsjiYJYxGb15dqL50I03YZXChwOREcpZ+J\nD/x7qcTQsK8Y9ki1jUKDJtNQ8IYPldyWMlfIhLC9yBAC8v84YiIcgJac85UN\n09CIjgi4wTHH2wOWc+gT3d4jV7mtB5l8eYFNU1nwOB4AuKnc28xEz1F+8V2m\nGi6g\r\n=iubO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIARAAibwsXXESIy4t1S/INLp4wnEbfCMmPOCenmlcNvNAiAU97Zdg6wksAazMHz1r5uAPdxsu/5Vt8YkGaLvUTw3Hg=="}]},"_npmUser":{"name":"tli4","email":"a@tianyi.li"},"directories":{},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.6_1621503329968_0.25534764041279634"},"_hasShrinkwrap":false,"deprecated":"es5 not supported"},"1.3.7":{"name":"umi-request","version":"1.3.7","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.es.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"father-build --w","build":"father-build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","father-build":"^1.19.5","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"6fe176a130f702b920248d496aeb52cb1a072c8f","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.7","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-XkU2yVYl06G692tssUiKYDpJEY/oml7GIq9Kez6lTEM2fvNT1maKgJosYEuocmQac/2bksjNUS9ViFb112qRzA==","shasum":"1981c3b08205514ba25bb1af8017f6bf62e8a9cf","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.7.tgz","fileCount":5,"unpackedSize":71788,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrH7uCRA9TVsSAnZWagAAV2EP/inNuu3DC9VtIH0pcMsp\n+HW897yMi5XfpuuUkfgg5XF662byWBtnMAwTQTjuuKGKI7WeWTOcCdOrrOpC\nmslZIaIEGC3daKejsmFl+JMpVqT2+xjMFJsunbVwW8pZ470tNcX7U+d61AWx\nOmEySRMH+u6cRqUDqCwKz+UI8WazKX3LDqjcLqE0YMpW4i2d4S96yhW+Vg/l\nqv3G07ExYNdJW/e1f8UrJYgyadmO1CFyrK+wvCzN1SkwcbLcPC6pGB2moY8u\ngnbou90nmD1wAjQU6HaWNPr/QMFDbQMdeeeOvObYbgrpH8Lm397bYlE9Xlaa\nES86UnuYKbcZpkbIDexj2ZnK2Ll99ScDEaGOZmc67uQx5cjyJzSGIDb/Kbje\nAa2NN+5Z2giaDX8CvGVsFfwVkYr7Rc9ZQihWk4tN3H6LsNgzH7N46AQ6Q87D\nB4ZTSIM0qAARfuUtiDp7euCdDk6gK/2V5CLpSbn6LnHqGwWyIxAd/8YH1u3v\nZenQXypI23IK1MH5BSo+uhB6Y3Zu+qrY1n9DPKPagOMSWn4MUBoUPSwbJ+vg\neAfkw26Tx+LXXgPkPx/uCz1NZ98iBs6NlAAOeGXWaVoS1H+ch1vJr+SmUHDV\nLDMM+4hs9CDYQ6BZy9Q9wCH25AmMTI6ZUePsFMbd3vyvZP/DC8O6P5/peMBe\nANm3\r\n=q6ta\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtrKUXbdmwl2V400b+smdri/Xe7ZyfU8/tHcgDf4fmRwIgXc8qfJANIX+z6LzPqyMoMy/ZgTl6CY5t7Of61a/lvQ0="}]},"_npmUser":{"name":"tli4","email":"a@tianyi.li"},"directories":{},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.7_1621917421891_0.17178499452173268"},"_hasShrinkwrap":false,"deprecated":"broken package entry"},"1.3.8":{"name":"umi-request","version":"1.3.8","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.esm.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"father-build --w","build":"father-build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","father-build":"^1.19.5","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","prettier":"^2.3.0","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"abort-controller":"^3.0.0","isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"f86c873008cfec7aec656dd87ad01bc6d749f7d8","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.8","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-5JLK9ECQpt8SYDL2WsmCtMAqWOOeX6u7jh4PH3ONrYzygkF93z4aMyOiD6rBhxwpu8vMbF4jJLcWGQ1WuZa+pA==","shasum":"b6495508e6df1a2438c1b6262abb81d7f1480dac","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.8.tgz","fileCount":6,"unpackedSize":109464,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrJEKCRA9TVsSAnZWagAACBkP/11zd38843rZp6LbqYby\nMbNsxIpgOXH2muWHkSCbJZUv/uzWwTZPt/0C3ZriFSa7xodsup/buKa1jY9S\ntT7RbGOnNUiJTinVOHc7ti2aSQnJAY+ouUfcUEadNZvEkaEASgfHmQYxW7mA\nLkG4OcRmkEweMJVSu/qcXwgloP6walHeaqGw3YW5ix4sn8bafG5KhOZJVZkK\n3nK4nlC1qFgtKmsqlp9wn3EKRtkwKld48+qsasaHg9tJb7587YlxSf1ihik2\nrkpvu9viVj/UQDXHKsf05s5XWsF1FrlrUpzbkWUtfwfbvvOnfIjgcZ3X35a9\n/5juJl3ANCyl0KdsnCIh/jVy4CrqCJ+oVG+YWhnOIz5AscAdMn22/y0vabnS\n0QK+CNcAGQ97Jeckvh+paGcYftmzCYCa2zTmV+JmqES7gyBbxrfKeh/YV+U5\nCkzLywMO5JhMUvzXgefg707DXcwMDnzfypnDK92JNZ1VnDRJgWXTULi6swIh\ngR7iq4lCU1xZSpFWlgKNQ6rP4swVI8aJnRXUdPWvgvHitXAgSSWFtJnPRFSd\nGuTlUX6VXi9ettlWf0T1/pine4dzZBqQDy6troVxKb520eG+fgDlj8dvqCTg\naCzhnKiQWujECFCxau6GAQgHG0zp6pJDaYYXL8AJV3MKkyHFFWYlaZ7d4Z4g\nzrKP\r\n=Z9eR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHlpazQROILkDIslyHhqrjzb3qB+2h/q+C+yykLE6TJXAiEArGzwylpqwICdJ30gJMy6JYsaLB1kpI4Z8YXS+hAhOyM="}]},"_npmUser":{"name":"tli4","email":"a@tianyi.li"},"directories":{},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.8_1621922058301_0.8981080370556269"},"_hasShrinkwrap":false},"1.3.9":{"name":"umi-request","version":"1.3.9","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.esm.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"father-build --w","build":"father-build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rm -rf ./dist && npm run lint && npm run test && npm run build && np --no-cleanup --yolo --no-publish","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","father-build":"^1.19.5","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","prettier":"^2.3.0","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"d0f3a4527d0b06ba543568b486ddbb4554f1e5c2","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.3.9","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-vjm8N1PDP8r3oG2MqUw69luRP4X8ucwIGeEpzbBGpjLy6s/WH9LOgcTxw7ferwn3u4IXqOVawSaGHUrI17blVA==","shasum":"e745edc22e1eb83e9e8d02334a6d1ebae20b025e","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.3.9.tgz","fileCount":6,"unpackedSize":108532,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrbljCRA9TVsSAnZWagAATZgP/RZNPBrX9o+hOpx7ooJQ\nqaxPtQmCFy4xOZjJe/rv+UOf/v3EknEgtdAiExHhKqK51POVbBB0uaJ/egoX\neyw20TxHppdHtLdwMOuJ/V7Frq2lPpaXwRTHj1mQ0bWOSamYnS65xAC8dOVH\nyY49IDA0sp0ODHGBYo4CnjVcMCWKRTwNrWZdl9DTQYIIIWgkHb0CDfLvDTOT\nnQqPWwvowk1936AUYd1E23BpO0trASVLa2iG3AyW0Ywtb7IEpKfIYoR9M/Jf\nLOjowFwgDWeguhV/GWvjMy5MZCqsZXgc2cRUFj7rsz97pRlChCQar/Qa/63W\nlEeSEkVT27OrU8zYKKuU1QgjLAXHLwN1mEYlOcmB+17pib7iT+SH8ww0jMgW\nwPScyxhUeYNe/tfShf2fXxl1PAMjazJHousFwJqY9mIb4LC21C975eFA2L2u\ntEo7fhZlLP/mPtTz49nB3Aj3xp8dt+/scKOelSlSqgrs5J6GgBqUSuD9G7ow\nw/BdjQUWMA4tDqiHCVDE179stpjD3XzhCtaOMZiTJIbb1CN+cjZQs41ox1/L\nRld0mImoWbZnmHVJA06/GuWlzyJffzdBFq0k2dqaIofTyOdvJTAMUE5eBCsc\nJMw42Qmt57wv/eOhZydZOyMQ7ZZ4NDhTo6HF1O24DAGqSzJvt6kmYUnkiMhV\nyVum\r\n=LjYJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID3fAnDfrbCAYhAqgWXZMlekWSvjrcNIB8ZD0tUXP7sxAiEAi7H1dJ2Jz1ojvtv/4tkj3bvYlI3TBY+Eqa1n2+o23Po="}]},"_npmUser":{"name":"tli4","email":"a@tianyi.li"},"directories":{},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.3.9_1621997922547_0.7015321449706913"},"_hasShrinkwrap":false},"1.4.0":{"name":"umi-request","version":"1.4.0","description":"A request tool based on fetch.","main":"dist/index.js","module":"dist/index.esm.js","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"scripts":{"dev":"father-build --w","build":"father-build","test":"umi-test","test:watch":"umi-test --watch","test:cover":"umi-test --coverage","lint":"umi-lint src","ci":"npm run lint && npm run test:cover","coveralls":"cat ./coverage/lcov.info | coveralls","precommit":"umi-lint --staged --prettier --fix"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"license":"MIT","devDependencies":{"create-test-server":"2.3.1","debug":"^4.1.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-import":"^2.14.0","father-build":"^1.19.5","iconv-lite":"^0.4.24","jest":"^23.5.0","np":"5.0.2","prettier":"^2.3.0","query-string":"^6.9.0","typescript":"^3.0.3","umi":"^2.8.15","umi-lint":"^1.0.0-alpha.1","umi-plugin-library":"^1.1.6","umi-test":"^1.4.0","whatwg-fetch":"^3.0.0"},"dependencies":{"isomorphic-fetch":"^2.2.1","qs":"^6.9.1"},"types":"types/index.d.ts","gitHead":"7ac65e00e8c4eba822c217f2501b43924ac6afeb","homepage":"https://github.com/umijs/umi-request#readme","_id":"umi-request@1.4.0","_nodeVersion":"14.17.3","_npmVersion":"6.14.13","dist":{"integrity":"sha512-OknwtQZddZHi0Ggi+Vr/olJ7HNMx4AzlywyK0W3NZBT7B0stjeZ9lcztA85dBgdAj3KVk8uPJPZSnGaDjELhrA==","shasum":"ed0e54e47f043d2be06e691477f0890383f9dd8a","tarball":"https://registry.npmjs.org/umi-request/-/umi-request-1.4.0.tgz","fileCount":6,"unpackedSize":109051,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhQJLjCRA9TVsSAnZWagAAUesQAJK7NEF6wYrOtLSfyUDp\ndcbjnUeKKtbMBmWq4S6sYFsVGOoGCn+XuUPe4Tebyg77wrmLuqpZ/w14bfcs\nJMSfw/htXILs8Z3q3GdH5YJ9fY4+4tNSVlm+tSeuinF6ayQsiNKBuC74XR9T\np3mFxceqUoooF/aJvRe1v00vPh+O+uJqtKXQM0lUT+dALyMoni/GCuVA9auw\nSEWmyKxoL0jnE++GtVHFnEsgrtjCJMw8azFKggdsqo3ePQoO621zO3yqpLFB\nxgxFX+Ml0xYwSjrXV+Xfi/hQ5uaTO9Hol9yWFm3Oh5EciwZLb/ZBt3Q9UVHX\nHV0KGPjfLXnRnCb1g0pIL14tqJwSJ2X4JKY4hzRDlrbge6rVkIzbOAUwEvWu\nf6SCxrf6DnhYpSjAaA6v6Ucmvx8ZocpK5Div1O+tnlouDBMa+gdmT9WfTzFb\nSTZP0+IzbWx8LNCn2Yxao29TVZXaPuuU1XzzKhM5mAb7Ou9rudtY5WLwFFO4\n1fsczuhSrykN4od8cZLhkujcnoHhgkvyFQw4o8mFmbt1VfI8eiHSVCM65Dy0\njtCbRtbLoaIMKF09/vFlqWt046XSHMiBMjrBphND3bFHc3AclCQnVC3BtWeS\n6lbWBWWu4hERT+JmanN98Yl4V/II2MfJSOQFLxZqfU3VNceNAqTTPuJo6J5F\nXd2x\r\n=PG74\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpKp5uc/qcJwuzRRJXAoM4pBzkF6cKl7bj2raY7AVpuAIgH+MUonL/eNbvXqaBCry2LWctuF9p3tJ3WTjqndRFDaI="}]},"_npmUser":{"name":"chenshuai2144","email":"wasd2144@hotmail.com"},"directories":{},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"chenshuai2144","email":"wasd2144@hotmail.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/umi-request_1.4.0_1631621859189_0.981421629636444"},"_hasShrinkwrap":false}},"time":{"created":"2018-12-07T11:58:12.707Z","1.0.0-beta.1":"2018-12-07T11:58:12.824Z","modified":"2022-05-22T17:35:42.808Z","1.0.0":"2018-12-10T07:03:38.174Z","1.0.1-beta.1":"2018-12-19T03:47:28.691Z","1.0.1":"2018-12-24T08:53:09.969Z","1.0.2-beta.1":"2018-12-25T14:40:23.704Z","1.0.2":"2018-12-26T03:36:13.268Z","1.0.3":"2018-12-27T11:25:02.701Z","1.0.4":"2019-02-27T04:30:18.186Z","1.0.5":"2019-03-25T11:04:32.945Z","1.0.6":"2019-04-11T05:32:34.337Z","1.0.7":"2019-04-24T11:53:23.389Z","1.0.8":"2019-06-12T03:42:22.639Z","1.1.0":"2019-07-10T06:39:14.558Z","1.1.1":"2019-07-19T09:56:26.383Z","1.2.0-beta.1":"2019-07-23T02:41:09.957Z","1.2.0-beta.2":"2019-07-23T13:40:20.402Z","1.2.0-beta.3":"2019-07-24T08:42:07.115Z","1.2.0-beta.4":"2019-07-24T12:04:42.982Z","1.2.0":"2019-07-31T07:19:25.471Z","1.2.1":"2019-07-31T10:04:01.613Z","1.2.2":"2019-08-05T02:31:02.204Z","1.2.3-beta.1":"2019-08-16T02:27:25.133Z","1.2.3":"2019-08-22T03:04:13.913Z","1.2.4-beta.0":"2019-08-22T03:30:49.640Z","1.2.4-beta.1":"2019-08-26T03:22:00.863Z","1.2.4":"2019-08-29T06:51:49.783Z","1.2.5-beta.0":"2019-09-03T06:57:28.721Z","1.2.5":"2019-09-09T08:16:44.154Z","1.2.6-beta.0":"2019-09-23T07:29:57.863Z","1.2.6":"2019-09-23T08:37:12.521Z","1.2.7-beta.0":"2019-10-09T09:04:13.409Z","1.2.7":"2019-10-10T02:44:05.198Z","1.2.8":"2019-10-13T09:50:19.074Z","1.2.9":"2019-11-09T11:23:51.881Z","1.2.10":"2019-11-20T13:05:09.046Z","1.2.11":"2019-11-21T14:48:10.999Z","1.2.12":"2019-12-05T06:16:40.876Z","1.2.13":"2019-12-09T08:50:04.265Z","1.2.14":"2019-12-09T11:20:33.746Z","1.2.15":"2019-12-12T11:22:13.943Z","1.2.16":"2019-12-24T09:01:31.531Z","1.2.17":"2019-12-26T08:37:27.196Z","1.2.18":"2020-01-20T07:06:42.945Z","1.2.19":"2020-02-18T08:38:56.064Z","1.3.0":"2020-05-22T09:24:14.907Z","1.3.1":"2020-05-22T17:31:14.454Z","1.3.2-beta.0":"2020-05-25T06:57:00.072Z","1.3.2":"2020-05-25T07:25:23.373Z","1.3.3":"2020-05-27T06:25:47.930Z","1.3.4-beta.0":"2020-05-27T08:22:27.057Z","1.3.4":"2020-06-17T02:48:45.701Z","1.3.5":"2020-06-17T03:06:44.841Z","1.3.6":"2021-05-20T09:35:30.138Z","1.3.7":"2021-05-25T04:37:02.117Z","1.3.8":"2021-05-25T05:54:18.434Z","1.3.9":"2021-05-26T02:58:42.703Z","1.4.0":"2021-09-14T12:17:39.317Z"},"maintainers":[{"name":"sorrycc","email":"sorrycc@gmail.com"},{"name":"zinkey","email":"zinkey@vip.qq.com"},{"name":"yutingzhao1991","email":"yutingzhao1991@sina.com"},{"name":"xiaohuoni","email":"448627663@qq.com"},{"name":"chenshuai2144","email":"wasd2144@hotmail.com"},{"name":"litou.cjs","email":"chenjsh36@gmail.com"},{"name":"clock157","email":"clock157@163.com"},{"name":"tli4","email":"a@tianyi.li"}],"description":"A request tool based on fetch.","homepage":"https://github.com/umijs/umi-request#readme","repository":{"type":"git","url":"git+ssh://git@github.com/umijs/umi-request.git"},"author":{"name":"puwei","email":"junwei.pu@gmail.com"},"bugs":{"url":"https://github.com/umijs/umi-request/issues"},"license":"MIT","readme":"English | [简体中文](./README_zh-CN.md)\n\n# umi-request\n\nThe network request library, based on fetch encapsulation, combines the features of fetch and axios to provide developers with a unified api call method, simplifying usage, and providing common functions such as caching, timeout, character encoding processing, and error handling.\n\n[![NPM version](https://img.shields.io/npm/v/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n[![Build Status](https://img.shields.io/travis/umijs/umi-request.svg?style=flat)](https://travis-ci.org/umijs/umi-request)\n[![NPM downloads](http://img.shields.io/npm/dm/umi-request.svg?style=flat)](https://npmjs.org/package/umi-request)\n\n---\n\n## Supported features\n\n- url parameter is automatically serialized\n- post data submission method is simplified\n- response return processing simplification\n- api timeout support\n- api request cache support\n- support for processing gbk\n- request and response interceptor support like axios\n- unified error handling\n- middleware support\n- cancel request support like axios\n- make http request from node.js\n\n## umi-request vs fetch vs axios\n\n| Features             | umi-request            | fetch                  | axios          |\n| :------------------- | :--------------------- | :--------------------- | :------------- |\n| implementation       | Browser native support | Browser native support | XMLHttpRequest |\n| size                 | 9k                     | 4k (polyfill)          | 14k            |\n| query simplification | ✅                      | ❌                      | ✅              |\n| post simplification  | ✅                      | ❌                      | ❌              |\n| timeout              | ✅                      | ❌                      | ✅              |\n| cache                | ✅                      | ❌                      | ❌              |\n| error Check          | ✅                      | ❌                      | ❌              |\n| error Handling       | ✅                      | ❌                      | ✅              |\n| interceptor          | ✅                      | ❌                      | ✅              |\n| prefix               | ✅                      | ❌                      | ❌              |\n| suffix               | ✅                      | ❌                      | ❌              |\n| processing gbk       | ✅                      | ❌                      | ❌              |\n| middleware           | ✅                      | ❌                      | ❌              |\n| cancel request       | ✅                      | ❌                      | ✅              |\n\nFor more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](https://github.com/camsong/blog/issues/2) If you have good suggestions and needs, please mention [issue](https://github.com/umijs/umi/issues)\n\n## TODO Welcome pr\n\n- [x] Test case coverage 85%+\n- [x] write a document\n- [x] CI integration\n- [x] release configuration\n- [x] typescript\n\n## Installation\n\n```\nnpm install --save umi-request\n```\n\n## Example\n\nPerforming a `GET` request\n\n```javascript\nimport request from 'umi-request';\n\nrequest\n  .get('/api/v1/xxx?id=1')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\n// use options.params\nrequest\n  .get('/api/v1/xxx', {\n    params: {\n      id: 1,\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nPerforming a `POST` request\n\n```javascript\nrequest\n  .post('/api/v1/user', {\n    data: {\n      name: 'Mike',\n    },\n  })\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## umi-request API\n\nRequests can be made by passing relevant options to `umi-request`\n\n**umi-request(url[, options])**\n\n```javascript\nimport request from 'umi-request';\n\nrequest('/api/v1/xxx', {\n  method: 'get',\n  params: { id: 1 },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n\nrequest('/api/v1/user', {\n  method: 'post',\n  data: {\n    name: 'Mike',\n  },\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Request method aliases\n\nFor convenience umi-request have been provided for all supported methods.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\n## Creating an instance\n\nYou can use `extend({[options]})` to create a new instance of umi-request.\n\n**extend([options])**\n\n```javascript\nimport { extend } from 'umi-request';\n\nconst request = extend({\n  prefix: '/api/v1',\n  timeout: 1000,\n  headers: {\n    'Content-Type': 'multipart/form-data',\n  },\n});\n\nrequest\n  .get('/user')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\nCreate an instance of umi-request in NodeJS enviroment\n\n```javascript\nconst umi = require('umi-request');\nconst extendRequest = umi.extend({ timeout: 10000 });\n\nextendRequest('/api/user')\n  .then(res => {\n    console.log(res);\n  })\n  .catch(err => {\n    console.log(err);\n  });\n```\n\nThe available instance methods are list below. The specified options will be merge with the instance options.\n\n**request.get(url[, options])**\n\n**request.post(url[, options])**\n\n**request.delete(url[, options])**\n\n**request.put(url[, options])**\n\n**request.patch(url[, options])**\n\n**request.head(url[, options])**\n\n**request.options(url[, options])**\n\nMore umi-request cases can see [antd-pro](https://github.com/umijs/ant-design-pro/blob/master/src/utils/request.js)\n\n## request options\n\n| Parameter           | Description                                                      | Type                      | Optional Value                    | Default                    |\n| :------------------ | :--------------------------------------------------------------- | :------------------------ | :-------------------------------- | :------------------------- |\n| method              | request method                                                   | string                    | get , post , put ...              | get                        |\n| params              | url request parameters                                           | object or URLSearchParams | --                                | --                         |\n| data                | Submitted data                                                   | any                       | --                                | --                         |\n| headers             | fetch original parameters                                        | object                    | --                                | {}                         |\n| timeout             | timeout, default millisecond, write with caution                 | number                    | --                                |\n| timeoutMessage      | customize timeout error message, please config `timeout` first   | string                    | --                                | --                         |\n| prefix              | prefix, generally used to override the uniform settings prefix   | string                    | --                                | --                         |\n| suffix              | suffix, such as some scenes api need to be unified .json         | string                    | --                                |\n| credentials         | fetch request with cookies                                       | string                    | --                                | credentials: 'same-origin' |\n| useCache            | Whether to use caching (only support browser environment)        | boolean                   | --                                | false                      |\n| validateCache       | cache strategy function                                          | (url, options) => boolean | --                                | only get request to cache  |\n| ttl                 | Cache duration, 0 is not expired                                 | number                    | --                                | 60000                      |\n| maxCache            | Maximum number of caches                                         | number                    | --                                | 0(Infinity)                |\n| requestType         | post request data type                                           | string                    | json , form                       | json                       |\n| parseResponse       | response processing simplification                               | boolean                   | --                                | true                       |\n| charset             | character set                                                    | string                    | utf8 , gbk                        | utf8                       |\n| responseType        | How to parse the returned data                                   | string                    | json , text , blob , formData ... | json , text                |\n| throwErrIfParseFail | throw error when JSON parse fail and responseType is 'json'      | boolean                   | --                                | false                      |\n| getResponse         | Whether to get the source response, the result will wrap a layer | boolean                   | --                                | fasle                      |\n| errorHandler        | exception handling, or override unified exception handling       | function(error)           | --                                |\n| cancelToken         | Token to cancel request                                          | CancelToken.token         | --                                | --                         |\n\nThe other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)\n\n## extend options Initialize default parameters, support all of the above\n\n| Parameter | Description            | Type   | Optional Value       | Default |\n| :-------- | :--------------------- | :----- | :------------------- | :------ |\n| method    | request method         | string | get , post , put ... | get     |\n| params    | url request parameters | object | --                   | --      |\n| data      | Submitted data         | any    | --                   | --      |\n| ...       |\n\n```javascript\n{\n  // 'method' is the request method to be used when making the request\n  method: 'get', // default\n\n  // 'params' are the URL parameters to be sent with request\n  // Must be a plain object or a URLSearchParams object\n  params: { id: 1 },\n\n  // 'paramSerializer' is a function in charge of serializing 'params'. ( be aware of 'params' was merged by extends's 'params' and request's 'params' and URLSearchParams will be transform to plain object. )\n  paramsSerializer: function (params) {\n    return Qs.stringify(params, { arrayFormat: 'brackets' })\n  },\n\n  // 'data' 作为请求主体被发送的数据\n  // 适用于这些请求方法 'PUT', 'POST', 和 'PATCH'\n  // 必须是以下类型之一：\n  // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // - 浏览器专属：FormData, File, Blob\n  // - Node 专属： Stream\n\n  // 'data' is the data to be sent as the request body\n  // Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n  // Must be of one of the following types:\n  // 1. string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n  // 2. Browser only: FormData, File, Blob\n  // 3. Node only: Stream\n  data: { name: 'Mike' },\n\n  // 'headers' are custom headers to be sent\n  headers: { 'Content-Type': 'multipart/form-data' },\n\n  // 'timeout' specifies the number of milliseconds before the request times out.\n  // If the request takes longer than 'timeout', request will be aborted and throw RequestError.\n  timeout: 1000,\n\n  // ’prefix‘ used to set URL's prefix\n  // ( e.g. request('/user/save', { prefix: '/api/v1' }) => request('/api/v1/user/save') )\n  prefix: '',\n\n  // ’suffix‘ used to set URL's suffix\n  // ( e.g. request('/api/v1/user/save', { suffix: '.json'}) => request('/api/v1/user/save.json') )\n  suffix: '',\n\n  // 'credentials' indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n  // omit: Never send or receive cookies.\n  // same-origin: Send user credentials (cookies, basic http auth, etc..) if the URL is on the same origin as the calling script. This is the default value.\n  // include: Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls.\n  credentials: 'same-origin', // default\n\n  // ’useCache‘ The GET request would be cache in ttl milliseconds when 'useCache' is true.\n  // The cache key would be 'url + params + method'.\n  useCache: false, // default\n\n  // 'ttl' cache duration（milliseconds），0 is infinity\n  ttl: 60000,\n\n  // 'maxCache' are the max number of requests to be cached, 0 means infinity.\n  maxCache: 0,\n\n  // According to http protocal, request of GET used to get data from server, it's necessary to cache response data when server data update not frequently. We provide 'validateCache'\n  // for some cases that need to cache data with other method reqeust.\n  validateCache: (url, options) => { return options.method.toLowerCase() === 'get' },\n\n\n  // 'requestType' umi-request will add headers and body according to the 'requestType' when the type of data is object or array.\n  // 1. requestType === 'json' :(default )\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/json;charset=UTF-8',\n  //   ...options.headers,\n  // }\n  // options.body = JSON.stringify(data)\n  //\n  // 2. requestType === 'form':\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',\n  //   ...options.headers,\n  // };\n  // options.body = query-string.stringify(data);\n  //\n  // 3. other requestType\n  // options.headers = {\n  //   Accept: 'application/json',\n  //   ...options.headers,\n  // };\n  // options.body = data;\n  requestType: 'json', // default\n\n  // 'parseResponse' whether processing response\n  parseResponse: true, // default\n\n  // 'charset' This parameter can be used when the server returns gbk to avoid garbled characters.(parseResponse should set to true)\n  charset: 'gbk',\n\n  // 'responseType': how to processing response.(parseResponse should be true)\n  // The default value is 'json', would processing response by Response.text().then( d => JSON.parse(d) )\n  // Other responseType (text, blob, arrayBuffer, formData), would processing response by Response[responseType]()\n  responseType: 'json', // default\n\n  // 'throwErrIfParseFail': whether throw error or not when JSON parse data fail and responseType is 'json'.\n  throwErrIfParseFail: false, // default\n\n  // 'getResponse': if you need the origin Response, set true and will return { data, response }.\n  getResponse: false,// default\n\n  // 'errorHandler' error handle entry.\n  errorHandler: function(error) { /* 异常处理 */ },\n\n  // 'cancelToken' the token of cancel request.\n  cancelToken: null,\n}\n```\n\n### Extend Options\n\nSometimes we need to update options after **extend** a request instance, umi-request provide **extendOptions** for users to update options:\n\n```javascript\nconst request = extend({ timeout: 1000, params: { a: '1' } });\n// default options is: { timeout: 1000, params: { a: '1' }}\n\nrequest.extendOptions({ timeout: 3000, params: { b: '2' } });\n// after extendOptions: { timeout: 3000, params: { a: '1', b: '2' }}\n```\n\n## Response Schema\n\nThe response for a request contains the following information.\n\n```javascript\n{\n  // 'data' is the response that was provided by the server\n  data: {},\n\n  // 'status' is the HTTP status code from the server response\n  status: 200,\n\n  // 'statusText' is the HTTP status message from the server response\n  statusText: 'OK',\n\n  // 'headers' the headers that the server responded with\n  // All header names are lower cased\n  headers: {},\n}\n```\n\nWhen options.getResponse === false, the response schema would be 'data'\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: false }).then(function(data) {\n  console.log(data);\n});\n```\n\nWhen options.getResponse === true ，the response schema would be { data, response }\n\n```javascript\nrequest.get('/api/v1/xxx', { getResponse: true }).then(function({ data, response }) {\n  console.log(data);\n  console.log(response.status);\n  console.log(response.statusText);\n  console.log(response.headers);\n});\n```\n\nYou can get Response from `error` object in errorHandler or request.catch.\n\n## Error handling\n\n```javascript\nimport request, { extend } from 'umi-request';\n\nconst errorHandler = function(error) {\n  const codeMap = {\n    '021': 'An error has occurred',\n    '022': 'It’s a big mistake,',\n    // ....\n  };\n  if (error.response) {\n    // The request was made and the server responded with a status code\n    // that falls out of the range of 2xx\n    console.log(error.response.status);\n    console.log(error.response.headers);\n    console.log(error.data);\n    console.log(error.request);\n    console.log(codeMap[error.data.status]);\n  } else {\n    // The request was made but no response was received or error occurs when setting up the request.\n    console.log(error.message);\n  }\n\n  throw error; // If throw. The error will continue to be thrown.\n\n  // return {some: 'data'}; If return, return the value as a return. If you don't write it is equivalent to return undefined, you can judge whether the response has a value when processing the result.\n  // return {some: 'data'};\n};\n\n// 1. Unified processing\nconst extendRequest = extend({ errorHandler });\n\n// 2. Separate special treatment\n// If unified processing is configured, but an api needs special handling. When requested, the errorHandler is passed as a parameter.\nrequest('/api/v1/xxx', { errorHandler });\n\n// 3. not configure errorHandler, the response will be directly treated as promise, and it will be caught.\nrequest('/api/v1/xxx')\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    return errorHandler(error);\n  });\n```\n\n## Middleware\n\nExpressive HTTP middleware framework for node.js. For development to enhance before and after request. Support create instance, global, core middlewares.\n\n**Instance Middleware (default)** request.use(fn) Different instances's instance middleware are independence.\n**Global Middleware** request.use(fn, { global: true }) Different instances share global middlewares.\n**Core Middleware** request.use(fn, { core: true }) Used to expand request core.\n\nrequest.use(fn[, options])\n\n### params\n\nfn params\n\n- ctx(Object)：context, content request and response\n- next(Function)：function to call the next middleware\n\noptions params\n\n- global(boolean): whether global， higher priority than core\n- core(boolean): whether core\n\n### example\n\n1. same type of middlewares\n\n```javascript\nimport request, { extend } from 'umi-request';\nrequest.use(async (ctx, next) => {\n  console.log('a1');\n  await next();\n  console.log('a2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('b1');\n  await next();\n  console.log('b2');\n});\n\nconst data = await request('/api/v1/a');\n```\n\norder of middlewares be called:\n\n```shell\na1 -> b1 -> response -> b2 -> a2\n```\n\n2. Different type of middlewares\n\n```javascript\nrequest.use(async (ctx, next) => {\n  console.log('instanceA1');\n  await next();\n  console.log('instanceA2');\n});\nrequest.use(async (ctx, next) => {\n  console.log('instanceB1');\n  await next();\n  console.log('instanceB2');\n});\nrequest.use(\n  async (ctx, next) => {\n    console.log('globalA1');\n    await next();\n    console.log('globalA2');\n  },\n  { global: true }\n);\nrequest.use(\n  async (ctx, next) => {\n    console.log('coreA1');\n    await next();\n    console.log('coreA2');\n  },\n  { core: true }\n);\n```\n\norder of middlewares be called:\n\n```shell\ninstanceA1 -> instanceB1 -> globalA1 -> coreA1 -> coreA2 -> globalA2 -> instanceB2 -> instanceA2\n```\n\n3. Enhance request\n\n```javascript\nrequest.use(async (ctx, next) => {\n  const { req } = ctx;\n  const { url, options } = req;\n\n  if (url.indexOf('/api') !== 0) {\n    ctx.req.url = `/api/v1/${url}`;\n  }\n  ctx.req.options = {\n    ...options,\n    foo: 'foo',\n  };\n\n  await next();\n\n  const { res } = ctx;\n  const { success = false } = res;\n  if (!success) {\n    // ...\n  }\n});\n```\n\n4. Use core middleware to expand request core.\n\n```javascript\nrequest.use(\n  async (ctx, next) => {\n    const { req } = ctx;\n    const { url, options } = req;\n    const { __umiRequestCoreType__ = 'normal' } = options;\n\n    // __umiRequestCoreType__ use to identificat request core\n    // when value is 'normal' , use umi-request 's fetch request core\n    if (__umiRequestCoreType__ === 'normal') {\n      await next();\n      return;\n    }\n\n    // when value is not normal, use your request func.\n    const response = getResponseByOtherWay();\n\n    ctx.res = response;\n\n    await next();\n    return;\n  },\n  { core: true }\n);\n\nrequest('/api/v1/rpc', {\n  __umiRequestCoreType__: 'rpc',\n  parseResponse: false,\n})\n  .then(function(response) {\n    console.log(response);\n  })\n  .catch(function(error) {\n    console.log(error);\n  });\n```\n\n## Interceptor\n\nYou can intercept requests or responses before they are handled by then or catch.\n\n1. global Interceptor\n\n```javascript\n// request interceptor, change url or options.\nrequest.interceptors.request.use((url, options) => {\n  return {\n    url: `${url}&interceptors=yes`,\n    options: { ...options, interceptors: true },\n  };\n});\n\n// Same as the last one\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: true }\n);\n\n// response interceptor, chagne response\nrequest.interceptors.response.use((response, options) => {\n  response.headers.append('interceptors', 'yes yo');\n  return response;\n});\n\n// handling error in response interceptor\nrequest.interceptors.response.use(response => {\n  const codeMaps = {\n    502: '网关错误。',\n    503: '服务不可用，服务器暂时过载或维护。',\n    504: '网关超时。',\n  };\n  message.error(codeMaps[response.status]);\n  return response;\n});\n\n// clone response in response interceptor\nrequest.interceptors.response.use(async response => {\n  const data = await response.clone().json();\n  if (data && data.NOT_LOGIN) {\n    location.href = '登录url';\n  }\n  return response;\n});\n```\n\n1. instance Interceptor\n\n```javascript\n// Global interceptors are used `request` instance method directly\nrequest.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=yes`,\n      options: { ...options, interceptors: true },\n    };\n  },\n  { global: false }\n); // second paramet defaults { global: true }\n\nfunction createClient(baseUrl) {\n  const request = extend({\n    prefix: baseUrl,\n  });\n  return request;\n}\n\nconst clientA = createClient('/api');\nconst clientB = createClient('/api');\n// Independent instance Interceptor\nclientA.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientA`,\n      options,\n    };\n  },\n  { global: false }\n);\n\nclientB.interceptors.request.use(\n  (url, options) => {\n    return {\n      url: `${url}&interceptors=clientB`,\n      options,\n    };\n  },\n  { global: false }\n);\n```\n\n## Cancel request\n\n### Use AbortController\n\nBase on [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) that allows you to abort one or more Web requests as and when desired.\n\n```javascript\n// polyfill abort controller if needed\nimport 'yet-another-abortcontroller-polyfill'\nimport Request from 'umi-request';\n\nconst controller = new AbortController(); // create a controller\nconst { signal } = controller; // grab a reference to its associated AbortSignal object using the AbortController.signal property\n\nsignal.addEventListener('abort', () => {\n  console.log('aborted!');\n});\n\nRequest('/api/response_after_1_sec', {\n  signal, // pass in the AbortSignal as an option inside the request's options object (see {signal}, below). This associates the signal and controller with the fetch request and allows us to abort it by calling AbortController.abort(),\n});\n\n// 取消请求\nsetTimeout(() => {\n  controller.abort(); // Aborts a DOM request before it has completed. This is able to abort fetch requests, consumption of any response Body, and streams.\n}, 100);\n```\n\n### Use Cancel Token\n\n> Cancel Token still work, but we don’t recommend using them in the new code.\n\n1. You can cancel a request using a cancel token.\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nconst { token, cancel } = CancelToken.source();\n\nRequest.get('/api/cancel', {\n  cancelToken: token,\n}).catch(function(thrown) {\n  if (Request.isCancel(thrown)) {\n    console.log('Request canceled', thrown.message);\n  } else {\n    // handle error\n  }\n});\n\nRequest.post(\n  '/api/cancel',\n  {\n    name: 'hello world',\n  },\n  {\n    cancelToken: token,\n  }\n);\n\n// cancel request (the message parameter is optional)\ncancel('Operation canceled by the user.');\n```\n\n2. You can also create a cancel token by passing an executor function to the CancelToken constructor:\n\n```javascript\nimport Request from 'umi-request';\n\nconst CancelToken = Request.CancelToken;\nlet cancel;\n\nRequest.get('/api/cancel', {\n  cancelToken: new CancelToken(function executor(c) {\n    cancel = c;\n  }),\n});\n\n// cancel request\ncancel();\n```\n\n## Cases\n\n### How to get Response Headers\n\nUse **Headers.get()** (more detail see [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/Headers/get))\n\n```javascript\nrequest('/api/v1/some/api', { getResponse: true }).then(({ data, response }) => {\n  response.headers.get('Content-Type');\n});\n```\n\nIf want to get a custem header, you need to set [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) on server.\n\n### File upload\n\nUse FormData() contructor，the browser will add request header `\"Content-Type: multipart/form-data\"` automatically, developer don't need to add request header **Content-Type**\n\n```javascript\nconst formData = new FormData();\nformData.append('file', file);\nrequest('/api/v1/some/api', { method: 'post', data: formData });\n```\n\nThe Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names.[Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)\n\n## Development and debugging\n\n- npm install\n- npm run dev\n- npm link\n- Then go to the project you are testing to execute npm link umi-request\n- Introduced and used\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/umijs/umi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Code Contributors\n\n- @clock157\n- @yesmeck\n- @yutingzhao1991\n\n## LICENSE\n\nMIT\n","readmeFilename":"README.md"}