O
O
Oleg2021-09-22 21:32:08
Google Apps Script
Oleg, 2021-09-22 21:32:08

How to remove a value from an object?

Good afternoon.
Please tell me how to delete part of the data received via the API with a script.
When requested, I get an object of the following form

[
{number:0,totalPrice:1.0, barcode:7, countryName:Россия}
{number:1,totalPrice:2.0, barcode:8, countryName:Россия}
{number:2,totalPrice:3.0, barcode:6, countryName:Россия}
]


And I need to remove "number" from it.
I tried using delete and splice, but I can't delete the data and get the object without "number".
I wanted to delete it when processing the script, without an intermediate entry in the table.

function sendRequestSales() {

  let dateFrom = '2021-09-10'

  let url = URL + 'sales?dateFrom=' + dateFrom + 'T00:00:00.000Z&flag=1&key=' + TOKEN 
  let data = [];
  let fetch = UrlFetchApp.fetch(url); 
  
  let arr = JSON.parse(fetch.getContentText())

   let arr2 = arr.forEach(el => delete el[0])
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question