my vue code does not write the response properly, what went wrong? ----- App.vue ---- <template>
  <div class="app-container">
    <header class="app-header">
      <h1>API Request Client</h1>
      <p class="subtitle">Query descriptive analytics from your API endpoint</p>
    </header>

    <main class="app-main">
      <div class="request-form">
        <div class="form-group">
          <label for="apiUrl">API Endpoint</label>
          <input
            type="text"
            id="apiUrl"
            v-model="apiUrl"
            placeholder="http://localhost:8080/descriptive"
            class="form-input"
          />
        </div>

        <div class="form-group">
          <label for="datasetPath">Dataset Path</label>
          <input
            type="text"
            id="datasetPath"
            v-model="datasetPath"
            placeholder="G:\projects\uv_rup99\handyscripts\products-100.csv"
            class="form-input"
          />
        </div>

        <div class="form-group">
          <label for="column">Column</label>
          <input
            type="text"
            id="column"
            v-model="column"
            placeholder="Price"
            class="form-input"
          />
        </div>

        <button
          @click="fetchData"
          :disabled="isLoading"
          class="submit-button"
        >
          <span v-if="!isLoading">Send Request</span>
          <span v-else class="loading-indicator">
            <span class="dot"></span>
            <span class="dot"></span>
            <span class="dot"></span>
          </span>
        </button>
      </div>

      <div class="results-container">
        <div v-if="statusMessage" class="status-message" :class="statusType">
          <div class="status-icon">
            <svg v-if="statusType === 'success'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
              <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M11,16.5L6.5,12L7.91,10.59L11,13.67L16.59,8.09L18,9.5L11,16.5Z" />
            </svg>
            <svg v-else-if="statusType === 'error'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
              <path fill="currentColor" d="M12,2C6.47,2 2,6.47 2,12C2,17.53 6.47,22 12,22C17.53,22 22,17.53 22,12C22,6.47 17.53,2 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 17.59,20 12,20M12,6C10.9,6 10,6.9 10,8C10,9.1 10.9,10 12,10C13.1,10 14,9.1 14,8C14,6.9 13.1,6 12,6M12,16C10.9,16 10,15.1 10,14C10,12.9 10.9,12 12,12C13.1,12 14,12.9 14,14C14,15.1 13.1,16 12,16Z" />
            </svg>
            <svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
              <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9Z" />
            </svg>
          </div>
          <div class="status-content">
            <p>{{ statusMessage }}</p>
            <div v-if="fullUrl" class="url-display">
              <span class="url-label">Request URL:</span>
              <code class="url-text">{{ fullUrl }}</code>
            </div>
          </div>
        </div>

        <div v-if="results" class="result-section">
          <h3>Response Preview</h3>
          <div class="json-container">
            <highlightjs
              language="json"
              :code="formattedResults"
              class="json-highlight"
            />
          </div>
          <button @click="copyToClipboard" class="copy-button">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
              <path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H10A2,2 0 0,0 8,3V5H6A2,2 0 0,0 4,7V19A2,2 0 0,0 6,21H18A2,2 0 0,0 20,19V10H18V8A2,2 0 0,0 16,6V3A2,2 0 0,0 16,1Z" />
            </svg>
            Copy to Clipboard
          </button>
        </div>

        <div v-if="errorDetails" class="error-section">
          <h3>Error Details</h3>
          <div class="error-content">
            <highlightjs
              language="json"
              :code="formattedError"
              class="json-highlight"
            />
          </div>
        </div>
      </div>
    </main>

    <footer class="app-footer">
      <p>API Client &copy; {{ new Date().getFullYear() }}</p>
    </footer>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { Highlightjs } from 'vue-highlightjs';
import 'highlight.js/styles/atom-one-dark.css';

// Reactive state
const apiUrl = ref('http://localhost:8080/descriptive');
const datasetPath = ref('G:\\projects\\uv_rup99\\handyscripts\\products-100.csv');
const column = ref('Price');
const fullUrl = ref('');
const statusMessage = ref('');
const statusType = ref('info'); // 'info', 'success', 'error'
const results = ref(null);
const errorDetails = ref(null);
const isLoading = ref(false);

// Computed properties
const formattedResults = computed(() => {
  return results.value ? JSON.stringify(results.value, null, 2) : '';
});

const formattedError = computed(() => {
  if (!errorDetails.value) return '';
  if (typeof errorDetails.value === 'object') {
    return JSON.stringify(errorDetails.value, null, 2);
  }
  return errorDetails.value;
});

// Methods
const fetchData = async () => {
  // Reset state
  isLoading.value = true;
  statusMessage.value = '';
  statusType.value = 'info';
  results.value = null;
  errorDetails.value = null;
  fullUrl.value = '';

  try {
    // URL-encode parameters
    const encodedDatasetPath = encodeURIComponent(datasetPath.value);
    const encodedColumn = encodeURIComponent(column.value);

    // Construct the full URL
    const constructedUrl = `${apiUrl.value}?datasetPath=${encodedDatasetPath}&column=${encodedColumn}`;
    fullUrl.value = constructedUrl;

    statusMessage.value = `Querying URL: ${constructedUrl}`;
    statusType.value = 'info';

    const response = await fetch(constructedUrl, {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
      },
    });

    if (response.ok) {
      const data = await response.json();

      if (data) {
        results.value = data;
        statusMessage.value = 'Request successful!';
        statusType.value = 'success';
      } else {
        statusMessage.value = 'Received an empty response from the API.';
        statusType.value = 'warning';
      }
    } else {
      statusType.value = 'error';
      let errorBody = 'Could not read error body.';

      try {
        const text = await response.text();
        try {
          errorBody = JSON.parse(text);
        } catch (e) {
          errorBody = text;
        }
      } catch (readError) {
        console.error("Failed to read error body:", readError);
      }

      statusMessage.value = `API request failed with status: ${response.status}`;
      errorDetails.value = {
        statusCode: response.status,
        statusText: response.statusText,
        body: errorBody,
      };
    }
  } catch (error) {
    console.error("An error occurred during the API request:", error);
    statusType.value = 'error';
    statusMessage.value = 'An error occurred during the API request.';
    errorDetails.value = {
      message: error.message,
      stack: error.stack,
    };
  } finally {
    isLoading.value = false;
  }
};

const copyToClipboard = () => {
  if (!results.value) return;

  navigator.clipboard.writeText(formattedResults.value)
    .then(() => {
      statusMessage.value = 'Copied to clipboard!';
      statusType.value = 'success';
      setTimeout(() => {
        if (results.value) {
          statusMessage.value = 'Request successful!';
        }
      }, 2000);
    })
    .catch(err => {
      console.error('Failed to copy: ', err);
      statusMessage.value = 'Failed to copy to clipboard';
      statusType.value = 'error';
    });
};
</script>