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:
parent
de69c49d46
commit
979bbe2a7f
@ -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,
|
||||||
});
|
});
|
||||||
|
@ -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"/>
|
||||||
|
|
||||||
|
{data.heartrate.value}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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"/>
|
||||||
|
|
||||||
|
{hours}:{minutes}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user