Accessing Object inside Array

27
June 13, 2018, at 2:40 PM

I'm trying to access values inside Firebase array > object.

When I try to access values inside v-for, it works well. But I cannot do this: postDetail.author. It returns undefined. What's the solution?

Answer 1

Since postDetail is an array of object to access properties inside its objects, you need do something like postDetail[Index].prop

var postDetail =[{"author" : "abc", "meta" : "xyz"}]; 
console.log(postDetail[0].author);

Answer 2

If you want get only author try it:

var postDetails = [{ 
  author: "John", 
  category: "Tech" 
}]; 
 
var inner = postDetails.map(function(e) { 
  return e.autor; 
}); 
 
console.log(inner);

READ ALSO
Use anchor element without href to toggle “hidden” attribute of separate element (div), without JavaScript

Use anchor element without href to toggle “hidden” attribute of separate element (div), without JavaScript

I've been browsing with JS disabled in my browser lately, out of curiosity to see how some sites handle it, and found some functionality on one site in particular that doesn't seem like it would be possible, based on what I know

54
flaticons not showing up in digitalocean - Ruby On Rails application

flaticons not showing up in digitalocean - Ruby On Rails application

I'm using following directory structure as shown in and added the following code in config/applicationrb but flaticons are not showing up in staging server digitalocean while working great on localhost

30
Sass-loader not replacing variables?

Sass-loader not replacing variables?

Not too long ago I made a project that used a combination of SASS variables and CSS custom propertiesI defined my Sass variables and then used those to create my CSS custom properties

69
Bootstrap width whitespace issue avilon theme

Bootstrap width whitespace issue avilon theme

I having issues that you can drag website to left and it seems like width is larger than viewport

42