@@ -5,11 +5,11 @@ export default component$(() => {
5
5
< article >
6
6
This example features an auto-complete component with a debounce of 150 ms.
7
7
< br />
8
- The function `debouncedGetPeople` needs to be exported because it is used in `useTask$`.
9
- < br />
10
8
< br />
11
9
Go ahead, search for Star Wars characters such as "Luke Skywalker", it uses the{ ' ' }
12
- < a href = "https://swapi.dev/" > Star Wars API</ a >
10
+ < a href = "https://swapi-node.vercel.app/" > Star Wars API</ a > :
11
+ < br />
12
+ < br />
13
13
< AutoComplete > </ AutoComplete >
14
14
</ article >
15
15
) ;
@@ -60,22 +60,23 @@ export const SuggestionsListComponent = (props: { state: IState }) => {
60
60
return < li onClick$ = { ( ) => ( props . state . selectedValue = suggestion ) } > { suggestion } </ li > ;
61
61
} ) }
62
62
</ ul >
63
- ) : (
63
+ ) : props . state . searchInput ? (
64
64
< p class = "no-results" >
65
- < em > No suggestions, you re on your own! </ em >
65
+ < em > No results </ em >
66
66
</ p >
67
- ) ;
67
+ ) : null ;
68
68
} ;
69
69
70
70
const getPeople = ( searchInput : string , controller ?: AbortController ) : Promise < string [ ] > =>
71
- fetch ( `https://swapi.dev /api/people/?search=${ searchInput } ` , {
71
+ fetch ( `https://swapi-node.vercel.app /api/people/?search=${ searchInput } ` , {
72
72
signal : controller ?. signal ,
73
73
} )
74
74
. then ( ( response ) => {
75
75
return response . json ( ) ;
76
76
} )
77
77
. then ( ( parsedResponse ) => {
78
- return parsedResponse . results . map ( ( people : { name : string } ) => people . name ) ;
78
+ debugger ;
79
+ return parsedResponse . results . map ( ( people : any ) => people . fields . name ) ;
79
80
} ) ;
80
81
81
82
function debounce < F extends ( ...args : any ) => any > ( fn : F , delay = 500 ) {
@@ -91,4 +92,4 @@ function debounce<F extends (...args: any) => any>(fn: F, delay = 500) {
91
92
} ;
92
93
}
93
94
94
- export const debouncedGetPeople = debounce ( getPeople , 150 ) ;
95
+ const debouncedGetPeople = debounce ( getPeople , 150 ) ;
0 commit comments