Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829import {useQuery} from '@tanstack/react-query'
import {Agent} from '../session/agent'
const RQKEY_ROOT = 'service'export const RQKEY = (serviceUrl: string) => [RQKEY_ROOT, serviceUrl]
export function useServiceQuery(serviceUrl: string) { return useQuery({ queryKey: RQKEY(serviceUrl), queryFn: async () => { const agent = new Agent(null, {service: serviceUrl}) const res = await agent.com.atproto.server.describeServer() return res.data }, enabled: isValidUrl(serviceUrl), })}
function isValidUrl(url: string) { try { // eslint-disable-next-line @typescript-eslint/no-unused-vars const urlp = new URL(url) return true } catch { return false }}