【问题标题】:How do i fetch data with Axios that isn't json data我如何使用 Axios 获取不是 json 数据的数据
【发布时间】:2022-01-04 23:13:21
【问题描述】:

我如何使用 Axios 获取不是 json 数据的数据。例如来自网站the data i want to fetch的数据

【问题讨论】:

  • 请提供数据示例,我无法理解您所附的图像。你说的只是来自网站的数据是什么意思,解释清楚

标签: javascript axios fetch


【解决方案1】:

使用选项responseType

示例下载图片:https://stackoverflow.com/a/53230807/6250402

  // `responseType` indicates the type of data that the server will respond with
  // options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
  //   browser only: 'blob'
  responseType: 'json', // default

阅读更多:https://github.com/axios/axios

【讨论】:

    猜你喜欢
    • 2019-07-03
    • 2018-01-17
    • 1970-01-01
    • 2023-03-23
    • 2020-06-28
    • 2018-09-08
    • 1970-01-01
    • 2023-02-01
    • 2020-06-14
    相关资源
    最近更新 更多