@@ -9,49 +9,50 @@ import ApiRequest from '../ApiRequest/ApiRequest';
99 * @example ../../docs/Search/Search.md
1010 */
1111function Search ( props ) {
12- const url = 'https://api.spotify.com/v1/search' ;
13- const options = { ...props . options } ;
14- const type = [ ] ;
15- if ( props . album ) type . push ( 'album' ) ;
16- if ( props . artist ) type . push ( 'artist' ) ;
17- if ( props . playlist ) type . push ( 'playlist' ) ;
18- if ( props . track ) type . push ( 'track' ) ;
19- options . type = type . join ( ',' ) ;
20- options . q = props . query ;
12+ const url = 'https://api.spotify.com/v1/search' ;
13+ const options = { ...props . options } ;
14+ const type = [ ] ;
15+ if ( props . album ) type . push ( 'album' ) ;
16+ if ( props . artist ) type . push ( 'artist' ) ;
17+ if ( props . playlist ) type . push ( 'playlist' ) ;
18+ if ( props . track ) type . push ( 'track' ) ;
19+ options . type = type . join ( ',' ) ;
20+ options . q = props . query ;
21+ console . log ( '[Search]' , props ) ;
2122
22- return (
23- < ApiRequest url = { url } options = { options } >
24- { ( data , loading , error ) => {
25- return props . children ( data , loading , error ) ;
26- } }
27- </ ApiRequest >
28- ) ;
23+ return (
24+ < ApiRequest url = { url } options = { options } >
25+ { ( data , loading , error ) => {
26+ return props . children ( data , loading , error ) ;
27+ } }
28+ </ ApiRequest >
29+ ) ;
2930}
3031
3132Search . propTypes = {
32- /** Search query keywords and optional field filters and operators. */
33- query : PropTypes . string . isRequired ,
34- /** Get results for albums */
35- album : PropTypes . bool ,
36- /** Get results for artists */
37- artist : PropTypes . bool ,
38- /** Get results for playlists */
39- playlist : PropTypes . bool ,
40- /** Get results for tracks */
41- track : PropTypes . bool ,
42- /** Options object */
43- options : PropTypes . shape ( {
44- market : PropTypes . string ,
45- limit : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
46- offset : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
47- include_external : PropTypes . string
48- } ) ,
49- /** Process spotify data with render props using props.children as a function */
50- children : PropTypes . func . isRequired
33+ /** Search query keywords and optional field filters and operators. */
34+ query : PropTypes . string . isRequired ,
35+ /** Get results for albums */
36+ album : PropTypes . bool ,
37+ /** Get results for artists */
38+ artist : PropTypes . bool ,
39+ /** Get results for playlists */
40+ playlist : PropTypes . bool ,
41+ /** Get results for tracks */
42+ track : PropTypes . bool ,
43+ /** Options object */
44+ options : PropTypes . shape ( {
45+ market : PropTypes . string ,
46+ limit : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
47+ offset : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
48+ include_external : PropTypes . string
49+ } ) ,
50+ /** Process spotify data with render props using props.children as a function */
51+ children : PropTypes . func . isRequired
5152} ;
5253
5354Search . defaultProps = {
54- options : { }
55+ options : { }
5556} ;
5657
5758export default Search ;
0 commit comments