Skip to content

Commit ab75ecd

Browse files
made changes in code to get it review by copilot and found issues by it
1 parent e2e515b commit ab75ecd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/frontend/src/pages/document/Document.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ const Document = (): JSX.Element => {
1414
const [error, setError] = useState<string | null>(null);
1515
const [isLoading, setIsLoading] = useState<boolean>(false); // Step 1
1616

17-
const x = 12/0
1817
useEffect(() => {
1918
const getDocument = async (id: string) => {
2019
setIsLoading(true); // Step 2
2120
try {
2221
const response = await documentRead(id);
23-
const data = await response.json();
24-
setDocument(data);
22+
const data = await response.text() //response.json();
23+
setDocument(data as any); //made changes here with "as any"
2524
} catch (error) {
26-
console.error(error);
25+
console.error("Error:",error); // added "Error:"
2726
setDocument(null);
2827
} finally {
2928
setIsLoading(false); // Step 3
3029
}
3130
};
3231

3332
if (params.id) {
34-
getDocument(params.id);
33+
getDocument(params.id as string); //unnecessary cast
3534
}
3635
}, [params.id]);
3736

@@ -42,7 +41,7 @@ const Document = (): JSX.Element => {
4241
) : document ? (
4342
<p>{document.content}</p>
4443
) : (
45-
<h1>Document not found. Please try again.</h1>
44+
<h1>Document not found</h1>
4645
)}
4746
</>
4847
);

0 commit comments

Comments
 (0)