UNPKG

@droppii-org/chat-sdk

Version:

Droppii React Chat SDK

19 lines (18 loc) 607 B
import { useQuery } from "@tanstack/react-query"; import { QUERY_KEYS } from "../../services/query"; export const useFetchExternalLink = (url) => useQuery({ queryKey: [QUERY_KEYS.FETCH_EXTERNAL_LINK, url], queryFn: async () => { const res = await fetch(`https://api.microlink.io?url=${encodeURIComponent(url)}`) .then((res) => res.json()) .then((res) => { return res; }) .catch(() => { return null; }); return res === null || res === void 0 ? void 0 : res.data; }, enabled: !!url, retry: 0, });