loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Getting array of only values from Get API

Open sukheja-varun opened this issue 9 years ago • 2 comments

I have a data model having data like: { "id": 1, "name": "A green door", "price": 12.50, "tags": ["home", "green"] }

I need an array of price only like: [12.50.5.7,9.2,23,45,78,34]

If I use Fields filter like: { fields: {price: true} } I get result something like this: [{price:12.50},{price:5.7},{price:9.2},{price:23},{price:45},{price:78},{price:34}]

sukheja-varun avatar Mar 23 '17 21:03 sukheja-varun

@sukheja-varun Try using lodash map function and pick price from it.

_.map(prices, 'price')

padelagani avatar Mar 25 '17 07:03 padelagani

@sukheja-varun +1 on lodash great solution for this kind of stuff and easy to pickup.

necevil avatar Apr 24 '17 14:04 necevil