I am creating a Backend API using Wix CLI. I have run ‘npm run generate’ to create HTTP functions.
On calling the GET method on the dashboard page, I am getting an error.
Here’s the implementation on the dashboard page:
import { httpClient } from ‘@wix/essentials’;
const callMyBackend = async () => {
try {
const apiUrl = import.meta.env.BASE_API_URL;
if (!apiUrl) return;
const res = await httpClient.fetchWithAuth(\`${apiUrl}/additional-fees\`, {
method: 'GET'
});
if (res.ok) {
const data = await res.json();
console.log(data);
}
} catch (err) {
console.error("Fetch failed:", err);
}
};
Here’s the error:
page.tsx:237 GET http://localhost:5173/functions/additional-fees 500 (Internal Server Error)
