UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

26 lines (25 loc) 633 B
import { useQuery as r } from "@tanstack/react-query"; const s = async (t, e) => { const n = t ? t.replace("https://doi.org/", "") : "", o = await fetch( `https://citation.doi.org/format?doi=${n}&style=${e}&lang=en-US`, { headers: { Accept: `text/x-${e}` } } ); if (!o.ok) throw new Error( `Failed to fetch citation: ${o.status}: ${o.statusText}` ); return await o.text(); }, i = (t, e, n) => r({ queryKey: ["citation", t, e], queryFn: () => s(t, e), enabled: !!t && !!e && n }); export { s as fetchCitation, i as useCitation }; //# sourceMappingURL=useCitation.js.map