用配置文件的方法发送axios请求

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
import axios from 'axios'
export default {
  mounted() {
  const ConfieBaseUrl   = 'http://127.0.0.1:8000/';
    // 配置请求默认信息
        const Service = axios.create({
            timeout:60000,
            responseType:'json',
            withCredentials:true,
        });
    //继续配置待插入的配置信息 const requestConfig
= { method:"POST", url: "123123", baseURL:ConfieBaseUrl, }   //传入原来已配置好的 (这里是追加的作用) Service(requestConfig).then( (response) =>{ console.log(response); }) .catch(function (error) { console.log(error); }) }} </script>

配置信息的参数:  https://www.kancloud.cn/yunye/axios/234845/

原文地址:https://www.cnblogs.com/kaibindirver/p/13678060.html