[英]how to fetch data from promise object which is in json format
我正在嘗試使用fetch現在計算與google api的距離,我將數據轉換為Promise對象中的json,而fromat的json是我的代碼,也是我現在得到的屏幕截圖
我嘗試到目前為止,但每次都會得到未定義的錯誤。
fetch(proxyurl + re)
.then(function(response) {
console.log (response.json());
});
我想獲取源和目標時間和距離的數據
嘗試像這樣更新您的提取方法:
fetch('https://api-endpoint.com')
.then(response => response.json())
.then(data => {
console.log(data);
});
帶有github用戶端點的演示: https : //codesandbox.io/s/prod-bush-wqn70
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.