etc

Axios

Axios

Posted by 동식이 블로그 on May 1, 2019

axios

  • Promise based HTTP client for the browser and node.js
  • 라이브러리
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        const URL = "https://jsonplaceholder.typicode.com/posts"
        // get을 요청하고, 그 요청값을 then
        // axios.get(URL).then((response) => {console.log(response.data)})

        const body = {
            title:"new post",
            body:"textext",
            userId:1
        }

        axios.post(URL, body).then(response => console.log(response.data))
    </script>
</body>
</html>