Axios GET svg请求

时间:2018-06-18 15:59:40

标签: javascript typescript svg axios

我试图让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;
}

0 个答案:

没有答案