|
1 | 1 | import { useInfiniteQuery, useQueries } from "@tanstack/react-query"; |
2 | 2 | import { useEffect } from "react"; |
3 | 3 | import type { StacCatalog, StacCollection, StacItem } from "stac-ts"; |
4 | | -import { fetchStac, fetchStacLink } from "../http"; |
| 4 | +import { fetchStac, fetchStacLink, makeAbsoluteUrl } from "../http"; |
5 | 5 | import type { StacCollections, StacValue } from "../types/stac"; |
6 | 6 |
|
7 | 7 | import { booleanValid } from "@turf/boolean-valid"; |
@@ -29,7 +29,10 @@ export default function useStacChildrenAndItems( |
29 | 29 | } |
30 | 30 |
|
31 | 31 | function useStacCollections(value: StacValue | undefined) { |
32 | | - const href = value?.links?.find((link) => link.rel == "data")?.href; |
| 32 | + const href = makeAbsoluteUrl( |
| 33 | + value, |
| 34 | + value?.links?.find((link) => link.rel == "data")?.href, |
| 35 | + ); |
33 | 36 | const { data, isFetching, hasNextPage, fetchNextPage } = |
34 | 37 | useInfiniteQuery<StacCollections | null>({ |
35 | 38 | queryKey: ["collections", href], |
@@ -67,7 +70,7 @@ function useStacLinks(value: StacValue | undefined, href: string | undefined) { |
67 | 70 | .map((link) => { |
68 | 71 | return { |
69 | 72 | queryKey: ["link", link, href], |
70 | | - queryFn: () => fetchStacLink(link, href), |
| 73 | + queryFn: () => fetchStacLink(link, makeAbsoluteUrl(value, href)), |
71 | 74 | }; |
72 | 75 | }) || [], |
73 | 76 | }); |
|
0 commit comments