try {
await axios({
method: "post",
url: `/member/wishlists?hotelId=${id}`,
headers: {
Authorization: localStorage.getItem("accessToken"),
},
});
await axios.post(`/member/wishlists?hotelId=${id}`, undefined, {
headers: {
Authorization: localStorage.getItem("accessToken"),
},
});
} catch (error) {
console.error(error);
}
๐ซ wishlist (ํํธ๋ฅผ ๋๋ฅด๋ฉด ์ฐ๊ธฐ๋ฅ)
์ฒ์์ await axios.post(/member/wishlists?hotelId=${id}
, {
headers: {
Authorization: localStorage.getItem("accessToken"),
},
});
๋ก ํ๋๋ฐ 403 Forbidden ์๋ฌ๊ฐ ๊ณ์ ๋ฐ์ (postman๊ณผ ๋ถ๋ช ๋์ผํ url์ธ๋ฐ axios๋ก ์๋์)
๊ฒ์ ๊ฒฐ๊ณผ, axios.postโ axios.post(url[, data[, config]]) ์ฌ์ ๋ณด๋ด์ฃผ๊ณ ์๋ data๊ฐ ์๋๋ฐ headers๋ฅผ data์๋ฆฌ์ ๊ณ์ ๋ณด๋ด์ฃผ๊ณ ์์ด์ ์๊ธด ์๋ฌ..await axios({
method: "post",
url:/member/wishlists?hotelId=${id}
,
headers: {
Authorization: localStorage.getItem("accessToken"),
},
});
์ด์ฉ์ง, ์๊ธฐ ๋ฐฉ๋ฒ๋ง ์๋ํด์ ๊ฐ์๋ง์ธ๋ฐ ์ ์๋์ง ํ๊ณ ์์๋๋ฐ..axios์ ๊ทผ๋ณธ ์ฌ์ฉ ๋ฐฉ๋ฒ์ ์ ๋๋ก ์์ง ๋ชปํจ..