Google Sheets Array Issue

Hi there,

I am trying to publish some API responses to a Google Sheet. I had been able to use this for the last 2 years but I believe the API changed just a little bit that is now causing the problem below.

Previously I had been using this: {{(table1.data).map(row => Object.assign(row, {home_line_scores:JSON.stringify(row.home_line_scores), away_line_scores:JSON.stringify(row.away_line_scores)}))}} to adjust the data for the column you see here (there is another one for the away data later in the table)
Screenshot 2025-03-23 at 1.42.59 PM

However, now I am getting this error:
Invalid values[1][17]: list_value { values { number_value: 20.0 } values { number_value: 24.0 } values { number_value: 14.0 } values { number_value: 21.0 } }

This corresponds with the homelinescore data in the sheet.

What do I need to modify to get this to push into Google sheets?

@DSomers16 ,

It seems like what you WERE getting from the api for home_line_scores was an array of numbers, like

  "home_line_scores": [20, 24, 14, 21] 

Does the current api now return it like this instead?

{
  "home_line_scores": [
    { "number_value": 20 },
    { "number_value": 24 },
    { "number_value": 14 },
    { "number_value": 21 }
  ]
}

If so, I think you need to map over the nested list and extract the number_value before applying the JSON.stringify, like this:

{{(table1.data).map(row => Object.assign(row, {
    home_line_scores: JSON.stringify(row.home_line_scores.map(score => score.number_value)),
    away_line_scores: JSON.stringify(row.away_line_scores.map(score => score.number_value))
}))}}

let me know if this works for you! :grinning:

Hey Linda!

Thanks for getting back to me. So it turns out the API just changed how it was passing those values: it is now homeLineScores. Naturally this was a much simpler fix than the amount of hair I pulled out my head trying to figure out what it could be lol. Appreciate you replying though!

Glad you sorted it out!