const access_token = ""
fetch('https://api.fitbit.com/1/user/-/profile.json', {
method: "GET",
headers: {"Authorization": "Bearer " access_token}
})
.then(response => response.json())
//.then(json => console.log(json))
.then((out) =>
{
console.log(out.data);
document.getElementById('log').innerHTML=out.data;
})
嗨,我一直在嘗試使用上面的 js 代碼獲取 wep API。我已經成功地在我的除錯控制臺中獲取了資料,但現在我想在我的 firebase 中獲取資料。有人可以幫忙嗎。出于安全目的,我洗掉了訪問令牌。
uj5u.com熱心網友回復:
確保out.data
是字串不是陣列或物件。
uj5u.com熱心網友回復:
您的代碼似乎還可以。您的訪問令牌不正確,或者您收到的 JSON 物件沒有“資料”鍵。
如果我在正確的頁面上,您似乎應該使用“out.user”而不是“out.data”: https ://dev.fitbit.com/build/reference/web-api/user/get-輪廓/
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/479889.html
標籤:javascript 火力基地 安慰 Fitbit
上一篇:如何避免在algolia上共享電子郵件,使用Firbase函式
下一篇:Reactjs不讀取.env檔案