axios基础(三):axios的常用基础配置

常用基础配置

// axios的常用默认配置
axios.defaults.method = 'GET';
axios.defaults.baseURL = 'http://localhost:3000';
axios.defaults.params = {
    
    id: 2};

btns[0].onclick = function() {
    
    
    axios({
    
    
        url: '/posts'
    }).then(response => {
    
    console.log(response);})
}

猜你喜欢

转载自blog.csdn.net/sinat_41696687/article/details/114876106
今日推荐