首页 > 解决方案 > 通过 https 提供的站点中通过 http 的 API 数据,脚本有“混合内容”错误

问题描述

标签: javascriptapicorsp5.jsmixed-content

解决方案


你可以这样使用fetch

fetch("https://cors-anywhere.herokuapp.com/http://api.open-notify.org/iss-now.json", {
    headers: { Origin: window.location.host }
  })
  .then(res => res.json())
  .then(res => {
    console.log(res);
    // gotData(res);
  })
  .catch(err => {
    console.log(err);
  });


推荐阅读