axios实例

<script>
    let newVar=axios.create({
        baseURL:'http://localhost:8080/student',
        timeout:5000
    });//创建axios实例

    let newVar1=axios.create({
        baseURL:'http://localhost:9999/student',
        timeout:5000
    });//创建axios实例
    newVar({
        url:'getAllStudent'
    }).then(res=>{
        console.log(res);
    });
    newVar1({
        url:'getStudentById'
    }).then(res=>{
        console.log(res);
    }).catch(err=>{
        console.log(err);
    });
    
</script>

  

posted @ 2020-12-24 22:04  Mr_sven  阅读(439)  评论(0编辑  收藏  举报