0
0
mirror of https://github.com/yude-jp/yude.jp synced 2024-12-22 12:10:11 +09:00

Fix implementation of heartrate retrieving, Update styling

This commit is contained in:
yude 2021-10-02 14:23:12 +09:00
parent de69c49d46
commit 979bbe2a7f
Signed by: yude
GPG Key ID: EB0FE5D925C4A968
3 changed files with 17 additions and 11 deletions

View File

@ -10,7 +10,7 @@ const today = format(new Date(), 'yyyy-MM-dd')
export const getName = async (props) => {
const uuid = props;
return fetch(
'https://api.fitbit.com/1/user/-/activities/heart/date/today/1d/1sec.json',
'https://api.fitbit.com/1/user/-/activities/heart/date/today/1d/1sec/time/00:00/23:59.json',
{
headers: {
Authorization: `Bearer ${bearer}`,
@ -26,14 +26,16 @@ const FitbitHeartrate = async (req, res) => {
if (response.status === 204 || response.status > 400) {
return res.status(200).send("404");
}
const heartrate = data["activities-heart"].map((item, i) => {
if (item.dateTime = today) {
return item.value.restingHeartRate
} else {
return "Failed to retrieve data."
}
}
)
// const heartrate = data.map((item, i) => {
// if (item.dateTime = today) {
// return item
// } else {
// return "Failed to retrieve data."
// }
// }
// )
const array = data["activities-heart-intraday"].dataset
const heartrate = array[array.length - 1]
return res.status(200).json({
heartrate,
});

View File

@ -26,7 +26,9 @@ function App (props) {
} else {
return (
<>
<FontAwesomeIcon icon={faHeartbeat} className="w-5 h-5 inline ml-3"/> {data.heartrate}
<FontAwesomeIcon icon={faHeartbeat} className="w-5 h-5 inline ml-3"/>
&nbsp;
{data.heartrate.value}
</>
)
}

View File

@ -32,7 +32,9 @@ function App (props) {
}
return (
<>
<FontAwesomeIcon icon={faBed} className="w-5 h-5 inline"/> {hours}:{minutes}
<FontAwesomeIcon icon={faBed} className="w-5 h-5 inline"/>
&nbsp;
{hours}:{minutes}
</>
)
}