SoFunction
Updated on 2025-04-12

Detailed explanation of AXIOS packaging in Vue

Create a network file separately

Create a

create

import axios from 'axios';
export function request1(config)
{
    const instance = ({
        baseURL: baseURL.url1,
        timeout: 5000
    })
    return instance(config)
}
export function request2(config){
    const instance = ({
        baseURL: baseURL.url2,
        timeout: 5000
    })
    return instance(config)
}

use

({
   url: 'http://'
}).then(
    res=>{
    }
);
({
    url: 'http://',
    data: {
    }
}).then(
    res=>{
    }
);

axios interceptor

Request Interceptor

export function request1(config)
{
    const instance = ({
        baseURL: baseURL.url1,
        timeout: 5000
    })
    (config=>{
        (config);  //The output is the configured object        return config
    },error => {
    })
    return instance(config);
}

Summarize

That’s all for this article. I hope it can help you and I hope you can pay more attention to more of my content!