-
Node.js 에서 axios 사용법 : get post put delet 및 req 로 데이터 받는 법axios 2023. 1. 30. 19:49
📌 get과 delete 는 {params : { data }} 구조로 보내고 req.query 로 받는다.
📌 post 와 put 은 { data } 구조로 보내고 req.body 로 받는다.
😥 이유 : 아직 정확하게 모르겠다. 이유를 알게되면 해당 글을 수정해야겠다
// get 요청 및 받는법 axios.get("/api/identify", {params: {email}}) router.get("/identify", async (req, res) => { const {email} = req.query; } // post 요청 및 받는법 axios.post("/api/login", {userid: userid, password: password}) router.post("/login", async (req, res) => { const { userid, password } = req.body; } // put 요청 및 받는법 axios.put("/api/home/like", {no: no, like: 1}) router.put("/home/like", (req, res) => { const { no, like } = req.body; } // delete 요청 및 받는법 axios.delete('/api/user', {params: {email: email, userid: userid}} ) router.delete("/user", (req, res) => { const { email, userid } = req.query; }
'axios' 카테고리의 다른 글
async await , then catch (feat. tryCatch) (0) 2023.05.11 React 에서 axios 요청하는 법 (0) 2023.02.24