首页 > 解决方案 > 如何从 github API 返回 atom/xml 提要

问题描述

我正在从 github API 获取 atom/xml 格式的公共提要。然而,我似乎只能得到 url 而没有任何数据。

我尝试在 fetch 标头中请求不同的内容,但它总是以 json 的形式返回。端点只显示 URL,我不确定如何从该 URL 中提取该数据以将其显示在我的应用程序中。

fetch("https://api.github.com/feeds", {
    mode: 'cors',
    headers: {
        'Content-Type': 'application/atom+xml'
    }})
  .then((res) => {
    console.log(res);
    return res.json();

  })
  .then((data) => {
    console.log(data._links.timeline.href);
    console.log(data);
    // this.setState( {feed: text});
    return data;
  })

标签: javascriptapi

解决方案


推荐阅读