Skip to content

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

Make `lang` prop dynamic.

Hossein Nedaee4ca78a2fe55d
diff --git a/components/ace-editor.vue b/components/ace-editor.vue
index d09c77108..ac8556f83 100644
--- a/components/ace-editor.vue
+++ b/components/ace-editor.vue
@@ -42,7 +42,6 @@ export default {
this.editor.session.setValue(value,1);
this.cacheValue = value;
}
-
},
theme() {
this.editor.setTheme('ace/theme/' + this.defineTheme())
diff --git a/pages/index.vue b/pages/index.vue
index 76ef31d7d..7705d9fbe 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -570,7 +570,7 @@
<div id="response-details-wrapper">
<ResponseBody
:value="responseBodyText"
- lang="json"
+ :lang="responseBodyType"
:options="{
maxLines: '16',
minLines: '16',
@@ -733,6 +733,7 @@ export default {
urlExcludes: {},
responseBodyText: '',
+ responseBodyType: 'text'
};
},
watch: {
@@ -753,18 +754,26 @@ export default {
else this.setRouteQueryState();
},
"response.body": function(val) {
- if (
- this.response.body !== "(waiting to send request)" &&
- this.response.body !== "Loading..."
+ if (
+ this.response.body === "(waiting to send request)" ||
+ this.response.body === "Loading..."
+ ) {
+ this.responseBodyText = this.response.body;
+ this.responseBodyType = 'text';
+ } else {
+ if(this.responseType === "application/json" ||
+ this.responseType === "application/hal+json"
) {
- this.responseBodyText =
- this.responseType === "application/json" ||
- this.responseType === "application/hal+json"
- ? JSON.stringify(this.response.body, null, 2)
- : this.response.body;
+ this.responseBodyText = JSON.stringify(this.response.body, null, 2)
+ this.responseBodyType = 'json'
+ } else if (this.responseType === "text/html") {
+ this.responseBodyText = this.response.body;
+ this.responseBodyType = 'html'
} else {
this.responseBodyText = this.response.body;
+ this.responseBodyType = 'text';
}
+ }
},
params: {
handler: function(newValue) {