import axios from "axios";
import {timeout, baseUrl, baseUrl_Address, withCredentials, baseUrl_Boat} from "@/service/config";
const requestInstance = axios.create({
    baseURL:baseUrl,
    timeout,
    method:"post",
    // withCredentials,
    // headers:{
    //
    //     "Content-Type":"application/x-www-form-urlencoded"
    // },
    // transformRequest:[(data) => {
    //
    //     if(data) {
    //         let params = new FormData()
    //         let keys = Object.keys(data)
    //         keys.forEach(key => {
    //             params.append(key,data[key])
    //         })
    //         return params
    //     }
    //     return data
    // }
    // ]
})
requestInstance.interceptors.request.use((config) => {
    return config
},(error) => {
    return new Error(error)
})

requestInstance.interceptors.response.use(function (res) {
    return res.data
},function (error) {
    return new Error(error)
})

export {
    requestInstance
}


const requestInstance_Address = axios.create({
    baseURL:baseUrl_Address,
    timeout,
    method:"post",
    // withCredentials,
    // headers:{
    //
    //     "Content-Type":"application/x-www-form-urlencoded"
    // },
    // transformRequest:[(data) => {
    //
    //     if(data) {
    //         let params = new FormData()
    //         let keys = Object.keys(data)
    //         keys.forEach(key => {
    //             params.append(key,data[key])
    //         })
    //         return params
    //     }
    //     return data
    // }
    // ]
})
requestInstance_Address.interceptors.request.use((config) => {
    return config
},(error) => {
    return new Error(error)
})

requestInstance_Address.interceptors.response.use(function (res) {
    return res.data
},function (error) {
    return new Error(error)
})

export {
    requestInstance_Address
}



const requestInstance_Boat = axios.create({
    baseURL:baseUrl_Boat,
    timeout,
    method:"post",
    // withCredentials,
    // headers:{
    //
    //     "Content-Type":"application/x-www-form-urlencoded"
    // },
    // transformRequest:[(data) => {
    //
    //     if(data) {
    //         let params = new FormData()
    //         let keys = Object.keys(data)
    //         keys.forEach(key => {
    //             params.append(key,data[key])
    //         })
    //         return params
    //     }
    //     return data
    // }
    // ]
})
requestInstance_Boat.interceptors.request.use((config) => {
    return config
},(error) => {
    return new Error(error)
})

requestInstance_Boat.interceptors.response.use(function (res) {
    return res.data
},function (error) {
    return new Error(error)
})

export {
    requestInstance_Boat
}
