0

I have a data object, and i want to get on of the value from it, when i try to print the data:

console.log(data);

i got an object like the image below :

result

the problem is i want to get the order[billing_address][country_id] which i think is an object, but i don't know how to fetch it. i've tried :

console.log(data.order); //didn't work
console.log(data.order[billing_address][country_id]);//didn't work
1
  • try data["order[billing_address][country_id]"] its a whole key Commented Feb 20, 2017 at 4:20

2 Answers 2

1

The name of the property is: "order[billing_address][country_id]"

To access its value try:

console.log(data['order[billing_address][country_id]'); // Should work
Sign up to request clarification or add additional context in comments.

Comments

1

It appears that the values you are looking for have keys that are the whole string:

"order[billing_address][telephone]"

You can access these values like this:

data["order[billing_address][telephone]"] //"5"

You are currently trying this:

data.order[billing_address][country_id]

What you are trying doesn't work because there are no variables billing_address or country_id that are defined, and the object is not that deeply nested - just has the above mentioned long string for a key.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.