-2

I am wondering how I can add this to the body of the Axios POST request.

  const res =  axios({
    method: 'post',
    url: 'https://fitness.googleapis.com/fitness/v1/users/me/dataset:aggregate',
    headers: {
      'Authorization': 'Bearer ACCESS_TOKEN'
    }
  });

I want to add this to the Body but I dont have a clue how to do it:

{
  "aggregateBy": [{
    "dataSourceId": "derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended" 
  }],
  "bucketByTime": { "durationMillis":86400000 },
  "startTimeMillis" : 1617667200000,
  "endTimeMillis" : 1617703858000
}
mick1996
  • 516
  • 9
  • 31

1 Answers1

0

Heres how I got it to work:

const res = await axios({
    method: 'post',
    url: 'https://fitness.googleapis.com/fitness/v1/users/me/dataset:aggregate',
    headers: {
      'Authorization': 'Bearer ACCESS_TOKEN'
    },
    data: {
      aggregateBy : [{
        dataSourceId : "derived:com.google.calories.expended:com.google.android.gms:platform_calories_expended"
      }],
      bucketByTime : {durationMillis : 86400000},
      startTimeMillis : 1617667200000,
      endTimeMillis : 1617703858000
    }
  });
mick1996
  • 516
  • 9
  • 31