I'm mapping through data in Reactjs. This JSX:
{place.venue.location.formattedAddress}
Is mapping through this Axios data request, specially, this array in my response:
formattedAddress: Array(5)
0 : "Chester Rd"
1 : "London"
2 : "Greater London"
3 : "NW1 4NR"
4 : "United Kingdom"
As a result, when I'm mapping, it returns the data, in one sentence, all joined together. Exactly like this:
Serpentine RdHyde ParkGreater LondonW2 2TP
I'm trying to map through, split and join with a line break, but it's not working. My address stops appearing completely. What am I doing wrong?
Here's my code, (I've sliced, so I can remove the country off the end of the address).
{place.venue.location.formattedAddress.slice(0,4).split(',').join('<br />')}
.splitmethod. IfformattedAddressis an array, thenformattedAddress.slice(...)returns another array. Just drop the.split.