N
Nuxt5mo ago
george.x.r

ssr calls to api do not work

Hi all, I am trying to get some data from my Stapi CMS through the API but I am getting an error. in my useGetData.ts composable I am making a call to the server/api/get-data. I am getting back a 500 error [GET] "http://localhost:1337/api/hello-world?locale=es-ES&populate=*": <no response> fetch failed. Calling the api from postman works ok. the api key and endpoints are correct. It is worth mentioning that if I change the enpoint from the local CMS to the one on the server everything works ok. Does the server/api have issues when calling APIs that run locally? useGetData.ts
const {data, seo} = await $fetch('/api/strapi/retrieve-data', {
method: 'POST',
body: {locale: iso, collection: collection},
})
const {data, seo} = await $fetch('/api/strapi/retrieve-data', {
method: 'POST',
body: {locale: iso, collection: collection},
})
server/api/get-data
const data = await $fetch(`${strapiURL}/api/${body.collection}`, {
method: "GET",
headers: {
"Authorization": `Bearer ${strapiToken}`
},
query: {locale: body.locale, populate: '*'}
});
const data = await $fetch(`${strapiURL}/api/${body.collection}`, {
method: "GET",
headers: {
"Authorization": `Bearer ${strapiToken}`
},
query: {locale: body.locale, populate: '*'}
});
2 Replies
oneeach
oneeach5mo ago
it looks like you're making a call to /api/strapi/retrieve-data and not /api/get-data
george.x.r
george.x.rOP5mo ago
ahh sorry that was a typo. i found what the issue was the issue was the cms was running under windows and the project in wsl
Want results from more Discord servers?
Add your server