loopback
loopback copied to clipboard
Getting array of only values from Get API
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 Try using lodash map function and pick price from it.
_.map(prices, 'price')
@sukheja-varun +1 on lodash great solution for this kind of stuff and easy to pickup.