Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I access this property in an object

I’m returning an object that has a key defined like this template[body]. Here is an example of the returned object:

object = {
 method: 'patch',
 authentication_token: 'a string',
 template[body]: 'another string',
 ...
}

How can I access the second value? I’m doing something like object.template[body] but I’m getting an error body is undefined

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

try this solution

You can access the value using object[‘template[body]’], like so:

let value = object[‘template[body]’];

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading