我剛剛完成了我的新聞站點,并且在 localhost 的 vs 代碼中運行時,它運行良好,但是在 gh-page api 中托管時無法正常作業。這是我的存盤庫的鏈接:- https://github.com/Ankitsahu640/Express-Time-News
這是托管 gh 頁面的鏈接:- https://ankitsahu640.github.io/Express-Time-News/
這就是我的網站在本地主機的 vs 代碼中看到的方式
uj5u.com熱心網友回復:
我試圖復制你的代碼,我意識到你發送請求的第三方 apihttps://newsapi.org/v2/top-headlines?country=in&apiKey=dbddeef57b58421aafd6a26534fd9d8d
不允許您從除本地主機之外的瀏覽器發送請求,這就是它在您的本地計算機上作業的原因。
這里是完整的回應:
{
status: "error",
code: "corsNotAllowed",
message: "Requests from the browser are not allowed on the Developer plan, except from localhost."
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/504126.html
標籤:javascript api github github页面 获取 API
上一篇:Git操作分支
