#TypeScript problem with fetch...
1 messages · Page 1 of 1 (latest)
The issue you're encountering is due to the way you're handling the fetch promise. In your current code, you're not returning anything from the .then() block, which is why you're getting a void type error when you try to use .map() on services.
Here's the problematic part of your code:
const services = await fetch(`<https://marctina-cms.up.railway.app/api/services/?populate=*`>)
.then(res => {res.json()})
You should return the result of res.json() like this:
const services = await fetch(`<https://marctina-cms.up.railway.app/api/services/?populate=*`>)
.then(res => res.json())
This way, services will be assigned the result of the res.json() promise, which should be the data you're trying to fetch. Then you should be able to use .map() on services.