从 reddit 拉取高分辨率图像 API

Pull hi res image from reddit API

我有一个简单的脚本可以从 subreddit 中获取图像:

唯一的问题是它拉低分辨率的拇指而不是高分辨率的图像。

fetch('https://www.reddit.com/r/RoomPorn.json')
  .then(res => res.json())
  .then(res => res.data.children)
  .then(res => res.map(post => ({
    author: post.data.author,
    link: post.data.url,
    img: post.data.thumbnail,
})))

.then(res => res.map(render))
.then(res => console.log(res))

const app = document.querySelector('#app');

const render = post => {
const node = document.createElement('div');
node.innerHTML = `
  <a href="${post.link}">
    <img src="${post.img}"/>
  </a>`;
app.appendChild(node);

}

是否可以改为拉高分辨率?

感谢您的宝贵时间,

尝试:

fetch('https://www.reddit.com/r/RoomPorn.json')
  .then(res => res.json())
  .then(res => res.data.children)
  .then(res => res.map(post => ({
    author: post.data.author,
    link: post.data.url,
    img: post.data.preview.images[0].source.url,
})))

顺便说一句 post.data.url 应该是来自原始来源的高分辨率图像 link。