.map() is not being read and I'm not to sure why?

22 Views Asked by At

When I run nodemon, i keep getting the message TypeError: Cannot read properties of undefined (reading 'map'), heres a link to my github https://github.com/Hixmixly/rest-rant. I don't really understand why, besides that i might need to change the name? Maybe make a var out of it?

const React = require('react')
const Def = require ('../default')

function index (data) {
    let placesFormatted = data.places.map((place) => {
      return (
        <div>
          <h2>{place.name}</h2>
          <img src={place.pic} alt={place.name}/>
        </div>
      )
    })
    return (
      <Def>
          <main>
              <h1>PLACES INDEX PAGE</h1>
              {placesFormatted}
          </main>
      </Def>
  )
  }
  
module.exports = index
const router = require ('express').Router()

// GET /places
router.get('/', (req, res) => {
      let places = [{
        name: 'H-Thai-ML',
        city: 'Seattle',
        state: 'WA',
        cuisines: 'Thai, Pan-Asian',
        pic: 'http://placekitten.com/250/250'
      }, {
        name: 'Coding Cat Cafe',
        city: 'Phoenix',
        state: 'AZ',
        cuisines: 'Coffee, Bakery',
        pic: 'http://placekitten.com/250/250'
      }]
    res.render('places/index', {places})
  })
  
  

    module.exports = router```



Well im expecting two images of cats displaying 
0

There are 0 best solutions below