-
-
-
- Pretty
+
+
+
+
+
+ Pretty
+
+
+
+ Raw
+
-
-
- Raw
-
+
+
-
-
-
-
-
@@ -134,9 +149,15 @@ const props = defineProps({
const emit = defineEmits(['response-fold']);
+type TableDataItem = {
+ name: String;
+ value: String;
+};
+
const activeIndex = ref
([]);
const tabActive = ref('body');
const responseType = ref('JSON');
+const tableData = ref([]);
const bodyTypeList = ref([
{
value: 'JSON',
@@ -207,10 +228,29 @@ const setEditorValue = () => {
activeIndex.value = [1];
};
+const setTableData = () => {
+ const { headers } = data.value;
+ if (headers && JSON.stringify(headers) !== '{}') {
+ const list: TableDataItem[] = [];
+ Object.keys(headers).forEach((key: string) => {
+ list.push({
+ name: key,
+ value: headers[key],
+ });
+ });
+
+ tableData.value = list;
+ } else {
+ tableData.value = [];
+ }
+};
+
watch(
() => tabActive.value,
- () => {
- setEditorValue();
+ (v) => {
+ if (v !== 'headers') {
+ setEditorValue();
+ }
},
);
@@ -220,6 +260,7 @@ watch(
data.value = v || {};
tabActive.value = 'body';
setEditorValue();
+ setTableData();
},
);