I´m learning to use apis and i have this array from an api
{
"candidate_id":1244,
"candidate_name": "ABRAHAM",
"vData": [
{
"document_name": "Identificación",
"document_status": 0,
"kind_document": 1,
"document_route": "",
"required": false
},
{
"document_name": "Comprobante de domicilio",
"document_status": 0,
"kind_document": 2,
"document_route": "",
"required": true
},
{
"document_name": "Estado de cuenta",
"document_status": 0,
"kind_document": 3,
"document_route": "",
"required": true
},
{
"document_name": "Doc. Datos Personares",
"document_status": 0,
"kind_document": 25,
"document_route": "",
"required": false
}
]
}
I can acces to the array this way console.log('lista: ', arrPayroll.archivo);
but I dont know how to spilt an use the content of it
I need to make something like
setvDocNameIdentificacion(vData.document_name);
setvKindDocument1(vData.kind_document);
where i want that vData.document_name is "Identificacion" and vData.kind_document is 1
//////////EDIT/////// what I need is a way to use the data inside of vData array to make some validations, so i need to put every elemnt of the arrays on diferent variables
for example since the first object on vData is
"document_name": "Identificación",
"document_status": 0,
"kind_document": 1,
"document_route": "",
"required": false
i need to use the elements to do something like this
setvDocumentName("Identificación")
setvDocumentstatus(0)
setvKindDocument(1),
setvDocument_route("")
setvRequired(false)
so i can use them for making views like
{vKindDocument == 1 ?
<Text style={styles.PaymentText}>El documento es {vDocumentName} </Text>
:
<Text style={styles.PaymentText}>No hay documento</Text>
}
any advice would be appreciated