I have followed this tutorial on how to get data from the google report api, i was able to download some sample code.
https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-js
First I got it to work in the Query explorer, but then i change the sample code, it fails.
Here is what I tried:
reportRequests: [
{
viewId: VIEW_ID,
dateRanges: [
{
startDate: "30daysAgo",
endDate: "today",
},
],
metrics: [
{
expression: "ga:sessions",
},
],
dimensions: [{ expression: "ga:date" }],
sort: [
{
expression: "ga:sessions",
},
],
},
],