umi-request 获取数据流

首发于 语雀文档

前言

微前端产品开发中使用到了 umi-request 这个,类似于 axios(但貌似又强于 axios),因为碰到文件下载的功能,也即是:获取数据流,记录一下。


其实最重要的两点无非是:

  1. responseType 要设置成 blob

https://github.com/blueju/umi-request-practice/blob/4f11c63e7b47f730ed1bcdde867c6f4575241485/example/get-data-stream.jsx#L14

  1. 如何将响应结果中的文件流导出来

https://github.com/blueju/umi-request-practice/blob/4f11c63e7b47f730ed1bcdde867c6f4575241485/example/get-data-stream.jsx#L16

Github

https://github.com/blueju/umi-request-practice.git

位置

![image.png](https://img-blog.csdnimg.cn/img_convert/8c16b01e31535a476f63da6d29566f37.png#align=left&display=inline&height=433&margin=[object Object]&name=image.png&originHeight=433&originWidth=1280&size=50040&status=done&style=none&width=1280)

猜你喜欢

转载自blog.csdn.net/BLUE_JU/article/details/111913803