0

I'm wonder how to properly access to object of objects.I have JSON API, and I have to get some data from It. FYI I'm using VueJS but I think that's not important thing here.

{
    "name": "Foo Bar",
    "details": {
        "color": "black",
        "slug": "foobar",
        "author": "John",
        "material": "Plastic"
    }
}

How could I access for e.g to the slug ? Those data are stored into parent object called product (VueJS Dev Tools)

Belmin Bedak
  • 9,011
  • 2
  • 40
  • 44

1 Answers1

0
var slug = product.details.slug
flott
  • 231
  • 1
  • 11
  • I tried this way for sure but I get error Cannot read property ... of undefined – Belmin Bedak Aug 19 '16 at 07:23
  • Well, then product is probably not defined or not accessible, try console.log(product). – flott Aug 19 '16 at 07:27
  • Seems like this could be Vue Related stuff, I'm not sure could I post here the vue code ? – Belmin Bedak Aug 19 '16 at 07:42
  • Your question did originally not seem to be Vue specific so the question was obviously closed. Personally I don't know anything about Vue, see if you can find any answer for this at google, else try to dig a little deeper to identify the problem and then make a new question. – flott Aug 19 '16 at 08:38