cloudflare/vinext

Public

mirrored from https://github.com/cloudflare/vinextAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
75742312bbb2dbd7f86e449da03fc5e6f1bc7f84

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

examples/hackernews/lib/get-comments.js

18lines · modecode

1import fetchData from './fetch-data'
2
3// hydrate comments based on an array of item ids
4export default function fetch(ids) {
5 return Promise.all(
6 ids.map(async (id) => {
7 const val = await fetchData(`item/${id}`)
8 return {
9 id: val.id,
10 user: val.by,
11 text: val.text,
12 date: new Date(val.time * 1000).getTime() || 0,
13 comments: await fetch(val.kids || []),
14 commentsCount: val.descendants || 0,
15 }
16 })
17 )
18}
19