Something went wrong. Try again.
Mirror of https://github.com/improsocial/improAn extensible Bluesky client for web
Something went wrong. Try again.
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839import { buildQueryString } from "/js/utils.js";import { CONSTELLATION_URL } from "/js/config.js";
export class Constellation { async getLinks({ subject, source, limit = null, timeout = 10000 }) { let cursor = null; const links = []; const controller = new AbortController(); if (timeout) { setTimeout(() => controller.abort(), timeout); } do { const query = { subject, source, limit: 100, }; if (cursor) { query.cursor = cursor; } const response = await fetch( `${CONSTELLATION_URL}/xrpc/blue.microcosm.links.getBacklinks?${buildQueryString( query, )}`, { headers: { Accept: "application/json", }, signal: controller.signal, }, ); const data = await response.json(); links.push(...data.records); cursor = data.cursor; } while (cursor && (limit ? links.length < limit : true)); return limit ? links.slice(0, limit) : links; }}