728x90
๋ฐ์ํ
๐จ ์ค๋ฅ ๋ฐ์
AxiosError message: 'Request failed with status code 400'
axios.delete(`${url}/unlike`, {
projectId: id,
})
axios์ delete๋ฅผ ์ฌ์ฉํ์ฌ ์๋ฒ์ ์์ฒญ์ ํ ๋, ๋ค์๊ณผ ๊ฐ์ด data๋ฅผ ์ ๋ฌํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
๐ก ํด๊ฒฐ ๋ฐฉ๋ฒ
axios.delete๋ request body๋ฅผ ์ง์ํ๋ฉฐ ๋ค์๊ณผ ๊ฐ์ด ๋๊ฐ์ ๋งค๊ฐ๋ณ์๋ฅผ ํ์ฉํ๋ค.
axios.delete(url[, config])
๐ config.data๋ request body๋ฅผ ์ค์ ํ๋๋ฐ ์ฌ์ฉํ ์ ์๋ค.
axios.delete(`${url}/unlike`, {
data: {
projectId: id,
},
})
2๋ฒ์งธ ์ธ์์์ data๋ฅผ data: {} ํํ๋ก ํ ๋ฒ ๋ ๊ฐ์ธ์ฃผ๋ฉด์ ์ค๋ฅ๋ฅผ ํด๊ฒฐโ
๐ป ์ฐธ๊ณ ํ ์ฌ์ดํธ
https://github.com/axios/axios/issues/897
Support delete body · Issue #897 · axios/axios
This is probably a design choice by the axios team and for good reason but I write all my POST/GET/PUTs like this: const res = await axios.post(url, { data: { ... } }) And my server sometimes expec...
github.com