umi-request
umi-request copied to clipboard
A request tool based on fetch.
把原来中间件全去去掉。
I use body to pass data to get api but it's not received by data. How to pass body to get request ? Thanks
## 背景 目前提供的 errorHandler 只能根据状态码来判断是否出错,但是很多后端 API 错误没有基于状态,直接 json 里通过 errorCode 或者 success 来标识,所以很多开发者不知道如何处理,我们现在推荐的是通过 interceptor 来做,但是拦截器拦截的错误还是会走到 errorHandler,不优雅也不好用。 ## 我的方案 增加一个 errorChecker 或者叫 errorDetector,识别错误 ```js const errorHandler = error => { }...
umi-request在next.js中使用,与next.js扩展的fetch一样吗,会具有扩展性吗? 原文:Next.js extends the native [fetch Web API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to allow you to configure the [caching](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data) and [revalidating](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) behavior for each fetch request on the server.
当下载二级制文件时,需要从 response header种 读取文件名字, example: Content-Disposition: attachment;filename=result_excel.xlsx 请问怎么配置才能拿到response header得值 axios demo: axios({ method: 'post', url: `${UrlConfig.ajaxurl}rule/exportResultList`, responseType: 'blob', data: params, headers: { } }).then(response => { const fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);...
上传进度条
请问有没有类似onUploadProgress这种回调 ,拿到上传进度
和#121一样的issue 没有使用umi全家桶,单独在项目中使用umi-request,如何mock请求
request.interceptors.response.use(async response => { const result = await response..json(); return Promise.resolve({ ...result, data: decrypt(result.data, secret) }); }); 代码如上,因为需要做ssr同构,node端直接采用了umi-request,使用过程中发现如果response中内容比较大的情况下,response..json()返回的promise对象处于pending状态,查看了源码发现使用了isomorphic-fetch库,而isomorphic-fetch库采用的是"node-fetch": "^1.0.1"版本的代码,在node-fetch1.x版本中的clone()方法代码如下: Body.prototype._clone = function(instance) { var p1, p2; var body = instance.body;...
我在responseInterceptors中抛出code!==200的错误,但是在errorhandler打印出response为null, 希望能在errorhandler中区分出http status!==200 和 业务错误码code!=='200'的两种错误, 我现在可以通过error.message这样区分,请问怎么才能区分毕竟合理?   request.interceptors.response.use(errorInterceptors);