0
0
mirror of https://github.com/yude-jp/yude.jp synced 2024-12-22 20:20:09 +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) => { export const getName = async (props) => {
const uuid = props; const uuid = props;
return fetch( 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: { headers: {
Authorization: `Bearer ${bearer}`, Authorization: `Bearer ${bearer}`,
@ -26,14 +26,16 @@ const FitbitHeartrate = async (req, res) => {
if (response.status === 204 || response.status > 400) { if (response.status === 204 || response.status > 400) {
return res.status(200).send("404"); return res.status(200).send("404");
} }
const heartrate = data["activities-heart"].map((item, i) => { // const heartrate = data.map((item, i) => {
if (item.dateTime = today) { // if (item.dateTime = today) {
return item.value.restingHeartRate // return item
} else { // } else {
return "Failed to retrieve data." // return "Failed to retrieve data."
} // }
} // }
) // )
const array = data["activities-heart-intraday"].dataset
const heartrate = array[array.length - 1]
return res.status(200).json({ return res.status(200).json({
heartrate, heartrate,
}); });

View File

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