refactor(index): replace instances of var with const

This commit is contained in:
jamesgeorge007
2019-11-26 14:24:27 +05:30
parent 113bf14718
commit b3680224cc

View File

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