我试图让Axios将SVG的获取请求视为文本,而不是JSON。 chrome中出现错误
Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "z".
我查找了Axios transformRequest配置属性,但我不确定这是否是让axios将SVG视为文本的方法。我还没有找到很多与此特定问题有关的在线资源。
功能如下:
export async function getSVG(url: string): Promise<string> {
const config = {responseType: 'text'};
const response = await axios.get(url, config);
const svgData = response.data;
return svgData;
}