Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: revert axios interceptor and use normal time data - fixed #1449
Liyas Thomas2b2c968a97b8
diff --git a/helpers/strategies/AxiosStrategy.js b/helpers/strategies/AxiosStrategy.jsindex 694d8e8e8..42f30c25a 100644--- a/helpers/strategies/AxiosStrategy.js+++ b/helpers/strategies/AxiosStrategy.js@@ -1,26 +1,6 @@import axios from "axios"import { decodeB64StringToArrayBuffer } from "../utils/b64"-axios.interceptors.request.use(- (config) => {- config.timeData = { startTime: new Date().getTime() }- return config- },- (error) => {- return Promise.reject(error)- }-)--axios.interceptors.response.use(- (response) => {- response.config.timeData.endTime = new Date().getTime()- return response- },- (error) => {- return Promise.reject(error)- }-)-let cancelSource = axios.CancelToken.source()export const cancelRunningAxiosRequest = () => {diff --git a/pages/index.vue b/pages/index.vueindex 63b2f6e67..0de570028 100644--- a/pages/index.vue+++ b/pages/index.vue@@ -1400,6 +1400,7 @@ export default {if (headers[id].key) headersObject[headers[id].key] = headers[id].value})headers = headersObject+ const startTime = new Date().getTime()try {this.runningRequest = trueconst payload = await this.makeRequest(@@ -1409,7 +1410,7 @@ export default {this.showPreRequestScript && this.preRequestScript)this.runningRequest = false- const duration = payload.config.timeData.endTime - payload.config.timeData.startTime+ const duration = new Date().getTime() - startTimethis.response.duration = durationthis.response.size = payload.headers["content-length"];(() => {@@ -1461,13 +1462,15 @@ export default {})()} catch (error) {this.runningRequest = false-// If the error is caused by cancellation, do nothingif (error === "cancellation") {this.response.status = this.$t("cancelled")this.response.body = this.$t("cancelled")} else {console.log(error)+ const duration = new Date().getTime() - startTime+ this.response.duration = duration+ this.response.size = Buffer.byteLength(JSON.stringify(error))if (error.response) {this.response.headers = error.response.headersthis.response.status = error.response.status