Access object properties in Javascript

后端 未结 2 1005
心在旅途
心在旅途 2021-01-29 03:50

I am trying to access email and password field but i dont know where this \'0\' came. I am retrieving object from rethinkdb and it looks good without \'0\'

相关标签:
2条回答
  • 2021-01-29 04:31

    you are retrieving array of data from database. That's how the 0 is coming. There should be a .first() method on db query or ORM you are using which will return single object of user not array.

    0 讨论(0)
  • 2021-01-29 04:43

    You can access like this,

    user['0'].email

    or

    user['0']['email']

    0 讨论(0)
提交回复
热议问题