The json data is a mixture of array and object. The object is well accessible. How do I access each of these data in an array? I think I can use map, but I get an error. I don't know how to pass values using the map method. Please Help.
<Query query={USER_QUERY}>
{
({loading, error, data }) => {
if (error) return 'error';
if (loading) return 'loading';
return (data.getUsers.history.dateInformation.map(data => (
<Fragment>
<p>User adid: </p>
{data.monthly.month}
</Fragment>)
));
}
}
</Query>
This is gql.
export const USER_QUERY = gql`
query{
getUsers{
gender
age
job
location {
dailyMovingAverage
home
mostStayingArea
office
}
history {
dateInformation {
monthly {
month
favorateTransitionService
movingCarRate
}
daily {
date
movingCarRate
}
}
}
}
}
This is json data.
{
"data": {
"getUsers": [
{
"gender": "F",
"age": "26",
"job": "student",
"location": {
"dailyMovingAverage": 3,
"home": "aaa",
"mostStayingArea": "aaaa",
"office": "aaa"
},
"history": {
"dateInformation": [
{
"monthly": [
{
"month": "March",
"favorateTransitionService": "Car",
"movingCarRate": 0,
...