File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -22,28 +22,26 @@ const SearchBar = () => {
2222 const debouncedSearch = useCallback (
2323 debounce ( async ( text : string ) => {
2424 if ( text . length > 1 ) {
25-
2625 try {
27- const searchResponse = await axios . get ( "http://localhost:3000 /api/search" , {
26+ const searchResponse = await axios . get ( "/api/search" , {
2827 params : { text } ,
2928 } ) ;
30-
29+
3130 const { res : encryptedSearchResponse } = searchResponse . data ;
3231 const decryptedSearchResponse = cryptr . decrypt ( encryptedSearchResponse ) ;
33- // console.log("Decrypted Search Response:", decryptedSearchResponse);
34-
3532 const { subjects } = JSON . parse ( decryptedSearchResponse ) ;
3633 const suggestionList = subjects . map ( ( subjectObj : { subject : string } ) => subjectObj . subject ) ;
3734 setSuggestions ( suggestionList ) ;
3835 } catch ( error ) {
39- setError ( "Error fetching suggestions" ) ;
40-
36+ const typedError = error as AxiosError < { message ?: string } > ;
37+ const errorMessage = typedError . response ?. data ?. message ?? "Error fetching suggestions" ;
38+ setError ( errorMessage ) ;
4139 }
4240 } else {
4341 setSuggestions ( [ ] ) ;
4442 }
45- } , 1000 ) ,
46- [ ]
43+ } , 1000 ) ,
44+ [ cryptr , axios ]
4745 ) ;
4846
4947 const handleSearchChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
You can’t perform that action at this time.
0 commit comments