Let's troubleshoot why your Vue app isn't displaying the API response properly. Here are the most likely issues and fixes:
1. CORS Issues
Your browser might be blocking the API request due to Cross-Origin Restrictions. Since you're making a request to http://localhost:8080, ensure your backend server allows cross-origin requests.
Fix:
Temporarily disable CORS in development (for testing):
Chrome: Use --disable-web-security flag
Or add CORS headers to your backend
Permanent fix: Configure your server to include these headers:
http
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
2. Incorrect URL Encoding
The PowerShell script uses .UrlEncode, while your Vue app uses encodeURIComponent. They should be equivalent, but let's verify:
Check:
Ensure datasetPath contains valid characters (no unescaped spaces or special characters)
Verify the constructed URL in the browser console:
javascript
console.log(constructedUrl);
3. Missing highlight.js Setup
Your template uses <highlightjs> but might not have properly installed/configured it.
Fix:
bash
npm install highlight.js vue-highlightjs
Then in your component:
javascript
import { defineComponent } from 'vue';
import { Highlightjs } from 'vue-highlightjs';
import 'highlight.js/styles/atom-one-dark.css'; // Ensure this is imported
export default defineComponent({
components: {
Highlightjs
},
// ... rest of your code
});
4. API Response Not Parsed Correctly
If the API returns non-JSON data (like HTML or malformed JSON), will fail.