mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 16:11:45 +03:00
fix /explore recursion due to useEffect (#164)
* fix: /explore recursion --------- Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
This commit is contained in:
parent
f69c64ead1
commit
0c6d7fded2
@ -18,31 +18,30 @@ export default function ExplorePage() {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
const fetchDocuments = async () => {
|
||||
setIsPending(true);
|
||||
try {
|
||||
console.log(
|
||||
`Fetching documents from ${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`
|
||||
);
|
||||
const response = await axios.get<{ documents: Document[] }>(
|
||||
`${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${session.access_token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
setDocuments(response.data.documents);
|
||||
} catch (error) {
|
||||
console.error("Error fetching documents", error);
|
||||
setDocuments([]);
|
||||
}
|
||||
setIsPending(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const fetchDocuments = async () => {
|
||||
setIsPending(true);
|
||||
try {
|
||||
console.log(
|
||||
`Fetching documents from ${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`
|
||||
);
|
||||
const response = await axios.get<{ documents: Document[] }>(
|
||||
`${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${session.access_token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
setDocuments(response.data.documents);
|
||||
} catch (error) {
|
||||
console.error("Error fetching documents", error);
|
||||
setDocuments([]);
|
||||
}
|
||||
setIsPending(false);
|
||||
};
|
||||
fetchDocuments();
|
||||
}, [fetchDocuments]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<main>
|
||||
|
Loading…
Reference in New Issue
Block a user