Thursday 19 January 2017

How to grab data from an array, to create another array of objects in the same order of objects.

I have an array like so: variants: [ { id: 36829111623, product_id: 9708754503, title: 'S / White', price: '19.99', sku: 'example-shirt-m-1', position: 1, grams: 200, inventory_policy: 'deny', compare_at_price: '24.99', fulfillment_service: 'manual', inventory_management: 'shopify', option1: 'S', option2: 'White', option3: null, created_at: '2017-01-18T05:41:15-05:00', updated_at: '2017-01-18T20:30:15-05:00', taxable: true, barcode: '', image_id: null, inventory_quantity: 1, weight: 0.44, weight_unit: 'lb', old_inventory_quantity: 1, requires_shipping: true }, { id: 36834204935, product_id: 9708754503, title: 'S / Blue', price: '19.99', sku: 'example-shirt-m-2', position: 2, grams: 200, inventory_policy: 'deny', compare_at_price: '24.99', fulfillment_service: 'manual', inventory_management: 'shopify', option1: 'S', option2: 'Blue', option3: null, created_at: '2017-01-18T06:58:08-05:00', updated_at: '2017-01-18T06:58:08-05:00', taxable: true, barcode: '', image_id: null, inventory_quantity: 1, weight: 0.44, weight_unit: 'lb', old_inventory_quantity: 1, requires_shipping: true }] Theres a lot of data that I dont need to save, ideally i need to have an array in the same order of the objects above but with this data: [{ price:, title:, id: }, { price:, title:, id: }]

Submitted January 20, 2017 at 02:55AM by farhansyed7911

No comments:

Post a Comment