今天出了好多这个错误,Uncaught (in promise) AxiosError {message: Request failed with status code 400 , name: AxiosError , code: ERR_BAD_REQUEST , config: {...}, request: XMLHttpRequest, ...}
反正就是前后端的参数不匹配,要不就是请求方式不匹配,比如前端请求的是post,但是后端用到putMapping
参数不匹配:
主要是改的前端,我这里后端基本是用的
@RequestParam Integer id
如果前端这样
javascript
const res = await myAxios.post("/blog/delete", id);
就会报400
但是修改为
javascript
const res = await myAxios.post("/blog/delete", null,
{
params: {id}
}
);
就可以了