Javascript Axios获取svg请求
我试图让Axios将SVG的get请求视为文本而不是JSON。chrome中产生了一个错误Javascript Axios获取svg请求,javascript,typescript,svg,axios,Javascript,Typescript,Svg,Axios,我试图让Axios将SVG的get请求视为文本而不是JSON。chrome中产生了一个错误 Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "z". 错误:属性d:应为moveto路径命令('M'或'M'),“z”。 我查找了Axios transformRequest config属性,但我不确定这是否是让Axios将SVG视为文本的方法。我也没有在网上找到很多与这个具体问题相关的资源
Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "z".
错误:属性d:应为moveto路径命令('M'或'M'),“z”。
我查找了Axios transformRequest config属性,但我不确定这是否是让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;
}
导出异步函数getSVG(url:string):Promise{
const config={responseType:'text'};
const response=await axios.get(url,config);
const svgData=response.data;
返回svgData;
}
能否将当前JavaScript添加到问题中?产生给定误差的部件。它将高度支持我们给您提供正确的建议。“我正试图让Axios将SVG的get请求视为文本而不是JSON。”-您收到的错误消息不可能是因为任何东西都试图将其解析为JSON。这看起来像是它试图将其解析为SVG,而SVG中有错误。@Quentin您能指出我可以从哪里了解如何调试此错误吗?这肯定是SVG错误,而不是javascript错误:)显示SVG!;)