aixos基础用法
<div> <button onclick="testGet()">GET请求</button> <button onclick="testPost()">POST请求</button> <button onclick="testPut()">PUT请求</button> <button onclick="testDelete()">DELETE请求</button> </div> <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.js"></script> <script> function testGet() { //GET请求 axios.get(‘http://localhost:3000/posts‘).then( response => { console.log(‘/posts‘, response.data); }) } function testPost() { //POST请求 axios.post(‘http://localhost:3000/posts‘, { "id": 5, "title": "balck-api", "author": "CCCC" }).then( response => { console.log(‘/posts‘, response.data); }) } function testPut() { //PUT请求 axios.put(‘http://localhost:3000/posts/4‘, { "id": 4, "title": "happy-api", "author": "CCCC" }).then( response => { console.log(‘/posts‘, response.data); }) } function testDelete() { //DELETE请求 axios.put(‘http://localhost:3000/posts/2‘).then( response => { console.log(‘/posts‘, response.data); }) } </script>
POST请求
Delete请求