Axios 避坑指南

80 阅读1分钟

bg : 服务端要求上传form-data形式的content-type,但是通过显式传递 content-type

headers: {
        'content-type': 'multipart/form-data; boundary=--------------------------931155213926469937405544'
    }

发现 服务端返回err, 所以正确使用方式应为

axios.post('https://example.com', form, { headers: form.getHeaders() })