UNPKG

513 BPlain TextView Raw
1import fetch from "isomorphic-unfetch";
2import { hnApiBaseUrl } from "./hn-api-base-url";
3import { Updated } from "./updated";
4
5/**
6 * `getLatestItemAndUserUpdates` returns the latest updates for items and users.
7 *
8 * @see {@link https://github.com/HackerNews/API#changed-items-and-profiles}
9 */
10export async function getLatestItemAndUserUpdates(): Promise<Updated> {
11 const endpoint = `${hnApiBaseUrl}/updates.json`;
12 const res = await fetch(endpoint);
13 const updates = await res.json();
14 return updates;
15}