【问题标题】:Add to the body of the Axios POST添加到 Axios POST 的正文中
【发布时间】:2021-07-02 03:37:21
【问题描述】:

我想知道如何将它添加到 Axios POST 请求的正文中。

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

我想将它添加到正文中,但我不知道该怎么做:

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

【问题讨论】:

标签: http axios google-fit google-fit-api


【解决方案1】:

这是我如何让它工作的:

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
    }
  });

【讨论】:

    猜你喜欢
    • 2020-10-01
    • 2014-12-05
    • 2021-12-05
    • 1970-01-01
    • 2016-01-23
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 2021-01-03
    相关资源
    最近更新 更多