Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Added cancel request function for network requests

Andrew Bastin0fccd3d5cb71
diff --git a/functions/network.js b/functions/network.js
index c58cc7fd1..5b45cc31c 100644
--- a/functions/network.js
+++ b/functions/network.js
@@ -1,5 +1,16 @@
-import AxiosStrategy from "./strategies/AxiosStrategy"
-import ExtensionStrategy, { hasExtensionInstalled } from "./strategies/ExtensionStrategy"
+import AxiosStrategy, { cancelRunningAxiosRequest } from "./strategies/AxiosStrategy"
+import ExtensionStrategy, {
+ cancelRunningExtensionRequest,
+ hasExtensionInstalled,
+} from "./strategies/ExtensionStrategy"
+
+export const cancelRunningRequest = (store) => {
+ if (isExtensionsAllowed(store) && hasExtensionInstalled()) {
+ cancelRunningExtensionRequest()
+ } else {
+ cancelRunningAxiosRequest()
+ }
+}
const isExtensionsAllowed = ({ state }) =>
typeof state.postwoman.settings.EXTENSIONS_ENABLED === "undefined" ||
@@ -13,7 +24,5 @@ const runAppropriateStrategy = (req, store) => {
return AxiosStrategy(req, store)
}
-const sendNetworkRequest = (req, store) =>
+export const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store).finally(() => window.$nuxt.$loading.finish())
-
-export { sendNetworkRequest }