I want to find the questionOption.title === "Ubication"
but I cannot access in the properties of question_option_history.questionOption
and I don't know why. This is an example:
The code:
const dataToFind = locationQuestion.question_option_history;
And this is the response:
[
{
"id": 234,
"answer": "Juan's house",
"questionOption": {
"id": 8,
"title": "Ubication details:"
}
},
{
"id": 233,
"answer": "30.888,-10.111",
"questionOption": {
"id": 7,
"title": "Ubication:"
}
}]
So, when I do question_option_history.questionOption.title
VSCode give me an error telling
title doesn't exist in QuestionOption[]
(QuestionOption y the entity).
I want to run the array and find what is the questionOption.title === "Ubication"
and take the answer
of that object. Because in that object I save the lat and long of the ubication.
This is what I want to do:
let dataToFind = locationQuestion.question_option_history.find(option => option.questionOption.title === "Ubication");
And take the answer
of dataToFind, to save the coordinates