Skip to content

TypeError: Cannot read property 'parroquia' of undefined with VUE.js #35

Open

Description

@edward4578

All render well until it reaches the object of the json parish .. I do not understand why it does not?
Because when I run the console.log brings me the correct data here I leave part of the code if anyone can help me .. Thank you very much

JSON:

{
"id": 1,
"cedula": "14748547",
"nombres": "Pepito",
"apellidos": "¨Pregunton",
"email": "pepitopregunton@gmail.com",
"telefono": "02128477447",
"direccion": "La Palomera",
"parroquia_id": 617,
"parroquia": {
"id": 617,
"parroquia": "BARUTA",
"municipio_id": 181,
"municipio": {
"id": 181,
"municipio": "BARUTA",
"estado_id": 13,
"estado": {
"id": 13,
"estado": "MIRANDA",
"activo": 0
}
}
},
"canaimas": [
{
"id": 1,
"modelo": "MG10T",
"deleted_at": null,
"activo": 1,
"pivot": {
"beneficiario_id": 1,
"canaima_id": 1,
"serial_canaima": "454DS5FDFD55",
"descripcion": "esta rayada"
}
},
{
"id": 6,
"modelo": "Canaima Docente VIT D2100",
"deleted_at": null,
"activo": 1,
"pivot": {
"beneficiario_id": 1,
"canaima_id": 6,
"serial_canaima": "kjdfbksjhgr43",
"descripcion": "NINGUNA"
}
}
]
}

html

×

Detalles

Cédula Nombres Apellidos Email Teléfono
Direccion <textarea v-model="beneficiario.direccion" class="form-control" readonly="readonly" name="direccion"></textarea> Estado Municipio Parroquia
# Modelo Serial Descripción
@{{item.id}} @{{item.modelo}} @{{item.pivot.serial_canaima}} @{{item.pivot.descripcion}}

vue.js

<script type="text/javascript"> new Vue({ el: '#beneficiario', created: function () { //this.showBeneficiario(); }, data: { beneficiario: [], errors: [], }, methods: { showBeneficiario: function (id) { var url = 'beneficiario/'+ id; axios.get(url).then(response => { this.beneficiario = response.data; $('#show').modal('show'); console.log(response.data.parroquia.parroquia); console.log(response.data.parroquia.municipio.municipio); console.log(response.data.parroquia.municipio.estado.estado); }); } } });</script>

Activity

  1. nigeldeakin commented on Feb 2, 2018

    @nigeldeakin
    Contributor

    It's not clear what connection your issue has with the Fn UI. Can you provide more information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions