添加到 Axios 的主体 POST
Add to the body of the Axios POST
我想知道如何将它添加到 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
}
下面是我如何让它工作的:
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
}
});
我想知道如何将它添加到 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
}
下面是我如何让它工作的:
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
}
});