Skip to content

Commit

Permalink
Merge pull request #105 from opentofu/improve-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Yantrio authored Sep 2, 2024
2 parents 48b419e + d2dd7b3 commit 6cd53da
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 245 deletions.
13 changes: 13 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.11",
"globals": "^15.9.0",
"ky": "^1.7.1",
"lunr": "^2.3.9",
"openapi-typescript": "^5.4.2",
"postcss": "^8.4.44",
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/q.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { queryOptions } from "@tanstack/react-query";
import lunr from "lunr";
import { api } from "./query";

export const getSearchIndexQuery = () =>
queryOptions({
queryKey: ["search-index"],
queryFn: async () => {
const response = await fetch(
`${import.meta.env.VITE_DATA_API_URL}/search.json`,
);
const data = await api(`search.json`).json();

const res = await response.json();

return lunr.Index.load(res);
return lunr.Index.load(data);
},
});
3 changes: 3 additions & 0 deletions frontend/src/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { QueryClient } from "@tanstack/react-query";
import ky from "ky";

export const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -7,3 +8,5 @@ export const queryClient = new QueryClient({
},
},
});

export const api = ky.create({ prefixUrl: import.meta.env.VITE_DATA_API_URL });
Loading

0 comments on commit 6cd53da

Please sign in to comment.