Closed anaismveras closed 2 years ago
MERN
can not get the images and the name of the city to know each other
const builtDestinationsSeparateInfo = [] const builtDestinations = [] const allInfo = props.destinationsData.concat(props.destinationsIncluded) allInfo.forEach(item => { // what is item if (item.relationships) { // console.log('featured image id', item.relationships.featured_photo.data) if (item.relationships.featured_photo.data != null) { // console.log('this is the image id',item.relationships.featured_photo.data.id) builtDestinationsSeparateInfo.push( {cityImageId: item.relationships.featured_photo.data.id, cityName: item.attributes.long_name}) } else { // console.log('there is not image found') builtDestinationsSeparateInfo.push({ cityImageId: 'There is not image for this city', ityName: item.attributes.long_name }) } } else if (item.attributes.image) { // console.log('this is the image url', item.attributes.image.large) builtDestinationsSeparateInfo.push( {imageUrl:item.attributes.image.large } // item.attributes.image.large ) } console.log('this is allInfo', builtDestinationsSeparateInfo) builtDestinationsSeparateInfo.map(item => { console.log('this is item', item) if (item.cityImageId || item.imageUrl) { builtDestinations.push( { CityInfo: item.cityImageId } ) } }) console.log('this is everything', builtDestinations)
no error
i cant figure out how to combine objects together
waaaaay too much
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
can not get the images and the name of the city to know each other
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
no error
What is your best guess as to the source of the problem?
i cant figure out how to combine objects together
What things have you already tried to solve the problem?
waaaaay too much