Currently running into an issue with Nuxt & Netlify. Dev works perfectly using the following code, as the response is automatically converted to an object. However, on Prod, the response._data.products
returns as a JSON string. JSON.parse
will get it to work on Prod with a bit of hacking to the pinia store, but it then causes it to fail on Dev.
const { data, error } = await useFetch(`${useRuntimeConfig().public.MAIN_URL}/.netlify/functions/getProducts`, {
onResponse({ request, response, options }) {
// Process the response data
productStore.products = response._data.products;
},
onResponseError({ request, response, options }) {
// Handle the response errors
console.error(response);
},
key: Date.now().toString(),
});
Production Response
Development Response
2