创建实例

    使用场景:当给多个服务器发送请求时,可以分别设置对应的实例

    1// 创建实例对象
    2const instance = axios.create({
    3  baseURL: "http://127.0.0.1:3000",
    4  timeout: 3000
    5})
    6
    7instance({
    8  url: "/posts"
    9}).then(response => {
    10  console.log(response)
    11})
    12
    13instance.get("/posts").then((response) => {
    14  console.log(response);
    15});