簡體   English   中英

如何修復我的 api 項目的 429 請求錯誤?

[英]How do I fix a 429 request error for my api project?

我正在嘗試從 FreeCodeCamp 構建一個非常簡單的項目,它使用 API 信息來提供天氣信息。 我正在使用 Heroku 應用程序,以便能夠在 API 仍然是本地主機時使用它。 但是,我收到 2 個錯誤,我不確定如何解決此問題。 有什么幫助嗎?

 window.addEventListener("load", ()=> { let long; let lat; if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(position => { long = position.coords.longitude; lat = position.coords.latitude; const proxy=`https://cors-anywhere.herokuapp.com/`; const api=`${proxy}https://api.openweathermap.org/data/2.5/onecall?lat=${lat}&lon=${long}& exclude={part}&appid={bdd50c9439280eb7362c1f796ce614ae}`; fetch(api).then(response =>{ return response.json(); }).then(data =>{ console.log(data); }) }); }else { h1.textContent = "hey dis is not working because not enabled" }; });
 * { margin:0; padding:0; box-sizing:border-box; } body { height:100vh; display:flex; justify-content: center; flex-direction: column; align-items: center; background: linear-gradient(rgb(47,150,163),rgb(48,62,143)); font-family: sans-serif; color:white; }.location,.temperature { height: 30vh; width:50%; display:flex; justify-content: space-around; align-items: center; }.temperature{ flex-direction: column; }.degree-section { display: flex; align-items: center; cursor: pointer; }.degree-section span{ margin: 10px; font-size:30px }.degree-section h2{ font-size: 40px; }
 <,DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"/> <link rel="stylesheet" href="./style.css"/> <title>Document</title> </head> <body> <div class="location"> <h1 class="location-timezone">Timezone</h1> <p>Icon</p> </div> <div class="temperature"> <div class="degree-section"> <h2 class="temp-degree">34</h2> <span>F</span> </div> <div class="temp-description">It's friggin cold</div> </div> <script src="app.js"></script> </body> </html>

在此處輸入圖像描述

HTTP 429 Too many requests響應狀態代碼表示用戶在給定時間內發送了太多請求(“速率限制”)。

您需要檢查實際限制是多少,並可能避免在頁面加載或超過其值時進行調用。

資源

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM