api-client/functions/strategies/AxiosStrategy.js

24 lines
526 B
JavaScript
Raw Normal View History

import axios from "axios"
2020-01-19 07:07:19 +00:00
const axiosWithProxy = async (req, { state }) => {
const { data } = await axios.post(
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
req
2020-02-24 18:44:50 +00:00
)
return data
}
const axiosWithoutProxy = async (req, _store) => {
2020-02-24 18:44:50 +00:00
const res = await axios(req)
return res
}
const axiosStrategy = (req, store) => {
2020-01-18 09:16:51 +00:00
if (store.state.postwoman.settings.PROXY_ENABLED) {
2020-02-24 18:44:50 +00:00
return axiosWithProxy(req, store)
2020-01-18 09:16:51 +00:00
}
2020-02-24 18:44:50 +00:00
return axiosWithoutProxy(req, store)
}
2020-02-24 18:44:50 +00:00
export default axiosStrategy