Quiero hacer referencia a mi base de datos de Strapi a mi interfaz Next.JS. ¿Cómo puedo hacer referencia a datos JSON si también es un objeto dentro del objeto?
Como ejemplo, para acceder al nombre, uso {activity.name} . ¿Cómo puedo acceder al nombre del providerName ?
Probé {activity.provider.providerName} pero no funciona. ¿Qué estoy haciendo mal?
[ { "id": 1, "name": "Bowling in Mundsburg", "activityType": "Bowling", "profileType": "Basic", "adventureType": "Activity", "slug": "bowling-in-new-york", "provider": { "id": 1, "providerName": "Bowlingcenter New York", "slug": "bowlingcenter-new-york", "published_at": "2021-09-26T12:06:12.670Z", "created_at": "2021-09-26T12:04:28.585Z", "updated_at": "2021-09-26T12:06:12.690Z" }, ... ]podrias intentar asi?
const strapiRes = [ { "id": 1, "name": "Bowling in Mundsburg", "activityType": "Bowling", "profileType": "Basic", "adventureType": "Activity", "slug": "bowling-in-new-york", "provider": { "id": 1, "providerName": "Bowlingcenter New York", "slug": "bowlingcenter-new-york", "published_at": "2021-09-26T12:06:12.670Z", "created_at": "2021-09-26T12:04:28.585Z", "updated_at": "2021-09-26T12:06:12.690Z" } } ]; const whatYouAreAskingFor = strapiRes[0].provider.providerNameAdemás, si está haciendo un bucle, intente algo como:
strapiRes.map(activity => activity.provider.providerName)