hussain
hussain

Reputation: 7083

How to get data from array of object?

Below data is printed in console.log , How can i print header from this array i tried below approach but i got error map is not a function, So this is server side nodejs , How can i get headers object from data ?

server.js

console.log(data);

var result = data.map(function(a) {return a.fieldName;});

    { file:
       [ { fieldName: 'file',
           originalFilename: 'sco_poc.bpmn',
           path: 'yGCNPv.bpmn',
           headers: [Object],
           size: 11078 } ] }

Upvotes: 0

Views: 93

Answers (2)

Simran
Simran

Reputation: 2810

You can solve above problem also using Lodash.

Here is an example:

 var result = _.map(data.file,function(value){
    return value.headers;
 });

 console.log(result);

jsfiddle

Upvotes: 0

XYZ
XYZ

Reputation: 4480

console.log(data.file[0].headers);

try this

OR This

var result = data.file.map(function(a) {
       console.log(a.headers);
        return a.headers;
 });

Upvotes: 4

Related Questions