Tdesign-React 请求接口 415 问题借助 chatmaster 模型处理记录

Tdesign-React 请求接口返回 415 问题处理记录。

官方模板基础上, 发现headers 中的 Content-Type 设置无效,接口浏览器返回 415,解决问题方案,1,将 Content-Type 改成 Content-Type1,Content-Type2 测试,发现有效。因此排查 request.ts 文件配置问题。 转到 请求源问题 const result = await request.get<IResult>('api/get-card-list'); 改成 const result = await request.get<IResult>('api/get-card-list', params);

headers: {

'Content-Type': DEFAULT_CONTENT_TYPE,

},

{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.13",
"title": "Unsupported Media Type",
"status": 415,
"traceId": "|cc833062-42465f5de63ad3a6."
}

复制代码
export const instance = axios.create({
  baseURL: API_HOST,
  timeout: TIMEOUT,
  withCredentials: true,
  headers: {
    'Content-Type': DEFAULT_CONTENT_TYPE,
  },
});

http 状态码 415 可通过 ai 查询解释,解释如图