I am trying to divide a JSON response by a number.
Here's my code:
function readData() {
var accesstoken = "TOKEN"
var sheet = SpreadsheetApp.getActiveSheet()
var campaignstatsurl = "https://adsapi.snapchat.com/v1/campaigns/e431cbcd-2281-49fe-8d05-b26c87660eb5/stats?&granularity=TOTAL&fields=impressions,swipes,video_views,view_completion,spend,video_views_time_based"
var campaignstatsurlresponse = UrlFetchApp.fetch(campaignstatsurl, {
headers: {
"Authorization": "Bearer " + accesstoken
}
});
var campaignstatsdata = JSON.parse(campaignstatsurlresponse.getContentText());
var spendvalues = campaignstatsdata.total_stats.map(({ total_stat: { stats } }) => [stats.spend])
sheet.getRange(3, 6, values.length).setValues(spendvalues);
}
I am trying to divide the
var spendvalues
By 1,000,000
I have tried the below:
sheet.getRange(3, 6, values.length).setValues(spendvalues/1000000);
I get the following error:
Exception: The parameters (number) don't match the method signature for SpreadsheetApp.Range.setValues.
Thank you for your help.