I am a little confused on the output of my variable ‘ready’ where I was hoping it will take the correct value from the json, which I was expecting to be ‘true’ but comes back with an array ['false', 'true']
and so it doesn’t go into the condition set. Does anyone know what it’s displaying an array with possible outcomes and not the value which I expect to be true?
Example JSON
{
"data": {
"competition": [
{
"events": [
{
"field": [
{
"ready": "true",
"__typename": "Field"
},
{
"ready": "true",
"__typename": "Field"
},
{
"ready": "true",
"__typename": "Field"
}
],
"__typename": "Event"
},
{
"field": [
{
"ready": "true",
"__typename": "Field"
},
{
"ready": "true",
"__typename": "Field"
},
{
"ready": "true",
"__typename": "Field"
}
],
"__typename": "Event"
}
],
"__typename": "Competition"
}
]
}
}
Code:
export function dailyListConverter(list) {
const ready = JSON.parse(list)
.data.competition[0].events.filter((event) => event.field)
.map((event) => event.field[0].ready);
if (ready === "true") {
console.log("I'M HERE")
}
console.log("OUTSIDE CONDITIONS")
}