axios的使用

 import axios from 'axios' 引入
 
npm install --save axios
 
 mounted () {

     //get请求拿数据
    // axios.get('http://localhost:3001/brands').then((res)=>{
    //  // console.log(res)
    //  const{status,data}=res
    //  if(status===200){
    //    console.log(data);
    //  }
    // }).catch((err)=>{
      
    // })
//port 增加数据
//axios.post(url,要添加的数据)
// axios.post('http://localhost:3001/brands',{
//   name:'张北',date:new Date()
// }).then((res)=>{
//   //如果是201就是添加成功
//   console.log(res)
// })

//pot 修改更新
// axios.put('http://localhost:3001/brands/8',{
//   name:'张北11111',date:new Date()
// });

//删除数据
//axios.delete('http://localhost:3001/brands/6');


   }

  

posted @ 2020-11-04 12:32  三号小玩家  阅读(110)  评论(0编辑  收藏  举报
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840