【发布时间】:2022-01-13 19:31:37
【问题描述】:
我有一个将图像作为字节数据返回的 API,但我不知道如何在 img 标签的 src 中显示这些字节
这就是我使用 axios 来使用 API 的方式
const getFile = async (nombreArchivo) => {
const tokenApp = window.localStorage.getItem('token')
const {data: res} = await axios.get(`${url}photo-2.jpg`,
{ headers: { Authorization: `${tokenApp}` },responseType: 'json',});
return res;};
【问题讨论】:
标签: reactjs api axios response-headers