Skip to content

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

refactor(index): replace instances of var with const

jamesgeorge007b3680224cc87
diff --git a/pages/index.vue b/pages/index.vue
index 3f7bf29e6..003fb233b 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1205,7 +1205,7 @@ export default {
},
requestCode() {
if (this.requestType === "JavaScript XHR") {
- var requestString = [];
+ const requestString = [];
requestString.push("const xhr = new XMLHttpRequest()");
const user = this.auth === "Basic" ? "'" + this.httpUser + "'" : null;
const pswd =
@@ -1259,14 +1259,14 @@ export default {
}
return requestString.join("\n");
} else if (this.requestType == "Fetch") {
- var requestString = [];
- var headers = [];
+ const requestString = [];
+ const headers = [];
requestString.push(
'fetch("' + this.url + this.pathName + this.queryString + '", {\n'
);
requestString.push(' method: "' + this.method + '",\n');
if (this.auth === "Basic") {
- var basic = this.httpUser + ":" + this.httpPassword;
+ const basic = this.httpUser + ":" + this.httpPassword;
headers.push(
' "Authorization": "Basic ' +
window.btoa(unescape(encodeURIComponent(basic))) +
@@ -1308,13 +1308,13 @@ export default {
requestString.push("})");
return requestString.join("");
} else if (this.requestType === "cURL") {
- var requestString = [];
+ const requestString = [];
requestString.push("curl -X " + this.method + " \\\n");
requestString.push(
" '" + this.url + this.pathName + this.queryString + "' \\\n"
);
if (this.auth === "Basic") {
- var basic = this.httpUser + ":" + this.httpPassword;
+ const basic = this.httpUser + ":" + this.httpPassword;
requestString.push(
" -H 'Authorization: Basic " +
window.btoa(unescape(encodeURIComponent(basic))) +
@@ -1672,7 +1672,7 @@ export default {
.then(() => {})
.catch(console.error);
} else {
- var dummy = document.createElement("input");
+ const dummy = document.createElement("input");
document.body.appendChild(dummy);
dummy.value = window.location.href;
dummy.select();
@@ -1709,8 +1709,8 @@ export default {
this.$toast.success("Copied to clipboard", {
icon: "done"
});
- var aux = document.createElement("textarea");
- var copy =
+ const aux = document.createElement("textarea");
+ const copy =
this.responseType == "application/json"
? JSON.stringify(this.response.body)
: this.response.body;
@@ -1725,9 +1725,9 @@ export default {
);
},
downloadResponse() {
- var dataToWrite = JSON.stringify(this.response.body, null, 2);
- var file = new Blob([dataToWrite], { type: this.responseType });
- var a = document.createElement("a"),
+ const dataToWrite = JSON.stringify(this.response.body, null, 2);
+ const file = new Blob([dataToWrite], { type: this.responseType });
+ const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = (