File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 11import { Error , Loader , SongCard } from '../components' ;
22import { genres } from '../assets/constants' ;
3+ import { useGetTopChartsQuery } from '../redux/services/shazamCore' ;
34
45const Discover = ( ) => {
6+ const { data, isFetching, error } = useGetTopChartsQuery ( ) ;
57 const genreTitle = 'Pop' ;
68
9+ console . log ( data ) ;
710 return (
811 < div className = "flex flex-col" >
912 < div className = "flex flex-col items-center justify-between w-full mt-4 mb-10 sm:flex-row" >
Original file line number Diff line number Diff line change 1+ import { createApi , fetchBaseQuery } from '@reduxjs/toolkit/query/react' ;
2+
3+ //delete - if path is ok
4+ // fetch('https://shazam.p.rapidapi.com/charts/track', options)
5+ // .then((response) => response.json())
6+ // .then((response) => console.log(response))
7+ // .catch((err) => console.error(err));
8+
9+ export const shazamCoreApi = createApi ( {
10+ reducerPath : 'shazamCoreApi' ,
11+ baseQuery : fetchBaseQuery ( {
12+ baseUrl : 'https://shazam.p.rapidapi.com' ,
13+ prepareHeaders : ( headers ) => {
14+ headers . set ( 'X-RapidAPI-Key' , '367d97e0d1msh37aed431a4b5cf2p1cd6dcjsn5ab9c1c9041d' ) ;
15+
16+ return headers ;
17+ } ,
18+ } ) ,
19+ endpoints : ( builder ) => ( {
20+ getTopCharts : builder . query ( { query : '/charts/track' } ) ,
21+ } ) ,
22+ } ) ;
23+
24+ export const { useGetTopChartsQuery } = shazamCoreApi ;
Original file line number Diff line number Diff line change 11import { configureStore } from '@reduxjs/toolkit' ;
22
33import playerReducer from './features/playerSlice' ;
4+ import { shazamCoreApi } from './services/shazamCore' ;
45
56export const store = configureStore ( {
67 reducer : {
8+ [ shazamCoreApi . reducerPath ] : shazamCoreApi . reducer ,
79 player : playerReducer ,
810 } ,
11+ middleware : ( getDefaultMiddleware ) => getDefaultMiddleware ( ) . concat ( shazamCoreApi . middleware ) ,
912} ) ;
You can’t perform that action at this time.
0 commit comments