Files
hoppscotch/functions/network.js
Liyas Thomas 01a890bce9 ♻️ Refactor
2020-01-21 17:55:35 +05:30

19 lines
588 B
JavaScript

import AxiosStrategy from "./strategies/AxiosStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy";
const runAppropriateStrategy = (req, store) => {
// The firefox plugin injects a function to send requests through it
// If that is available, then we can use the FirefoxStrategy
if (window.firefoxExtSendRequest) {
return FirefoxStrategy(req, store);
}
return AxiosStrategy(req, store);
}
const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store)
.finally(() => window.$nuxt.$loading.finish());
export { sendNetworkRequest };