Skip to content

get()

只有一个参数,参数为 url,若有查询条件在 url 后面拼接。

javascript
axios.get('http://localhost:3000/posts').then(res => {
  console.log(res);
})

post()

  1. 参数一:url
  2. 参数二:data
javascript
axios.post('http://localhost:3000/posts',{
  title: 'H5+C3',
  author: '张三'
}).then(res => {
  console.log(res);
})

pub()

  1. 参数一:url
  2. 参数二:data
javascript
axios.put('http://localhost:3000/posts/3',{
  title: 'H5+C3',
  author: '李四'
}).then(res => {
  console.log(res);
})

delete()

只有一个参数,参数为 url,url 后面一定要拼接一个删除对象的 id

javascript
axios.delete('http://localhost:3000/posts/3').then(res => {
  console.log(res);
})

基于 MIT 许可发布