File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
src/frontend/src/pages/document Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -14,24 +14,23 @@ const Document = (): JSX.Element => {
14
14
const [ error , setError ] = useState < string | null > ( null ) ;
15
15
const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ; // Step 1
16
16
17
- const x = 12 / 0
18
17
useEffect ( ( ) => {
19
18
const getDocument = async ( id : string ) => {
20
19
setIsLoading ( true ) ; // Step 2
21
20
try {
22
21
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"
25
24
} catch ( error ) {
26
- console . error ( error ) ;
25
+ console . error ( "Error:" , error ) ; // added "Error:"
27
26
setDocument ( null ) ;
28
27
} finally {
29
28
setIsLoading ( false ) ; // Step 3
30
29
}
31
30
} ;
32
31
33
32
if ( params . id ) {
34
- getDocument ( params . id ) ;
33
+ getDocument ( params . id as string ) ; //unnecessary cast
35
34
}
36
35
} , [ params . id ] ) ;
37
36
@@ -42,7 +41,7 @@ const Document = (): JSX.Element => {
42
41
) : document ? (
43
42
< p > { document . content } </ p >
44
43
) : (
45
- < h1 > Document not found. Please try again. </ h1 >
44
+ < h1 > Document not found</ h1 >
46
45
) }
47
46
</ >
48
47
) ;
You can’t perform that action at this time.
0 commit comments