【发布时间】:2021-04-19 21:00:24
【问题描述】:
当我尝试在 ReactJS 中调用此 GET 方法时,我遇到了问题。错误=“不支持的媒体类型”。但是当我在 POSTMAN 中调用方法时,它适用于 Content-type: application/json。
const API_URL="http://****/sample/";
class Service{
getKnjige(){
const token = getToken();
return axios.get(API_URL,{
headers:{'Content-Type': 'text/xml',
dataType: "json",}
})
}
错误:
{时间戳:“2021-01-14T19:22:39.096+0000”,状态:415,错误:“不支持的媒体类型”,...} 错误:“不支持的媒体类型” 消息:“不支持内容类型” 路径:“/样本/” 状态:415 时间戳:“2021-01-14T19:22:39.096+0000”
【问题讨论】:
标签: reactjs content-type http-status-code-415