@@ -5,6 +5,22 @@ import { Layout } from '../../Components'
55const RiotProfile = ( ) => {
66 const Auth = useContext ( AuthContext ) ;
77 const [ loading , setLoading ] = useState ( true ) ;
8+ const [ matchIds , setMatchIds ] = useState < string [ ] > ( [ ] ) ;
9+
10+ const fetchData = async ( ) => {
11+ const region = "na" ;
12+ const res = await fetch ( `https://${ region } .api.riotgames.com/val/match/v1/matchlists/by-puuid/${ Auth ?. puuid } ` , {
13+ method : 'GET' ,
14+ headers : {
15+ // Use an API key that actually allows fetching to this endpoint
16+ 'X-Riot-Token' : process . env . RIOT_DEVELOPER_API_KEY || ""
17+ }
18+ } ) ;
19+ const resJson = await res . json ( ) ;
20+ const newArray = resJson . data . map ( ( matchObj :any ) => matchObj . matchId ) ;
21+ setMatchIds ( [ ...matchIds , ...newArray ] )
22+ // use /val/match/v1/matches/{matchId} to get more in depth details of each match
23+ }
824
925 useEffect ( ( ) => {
1026 // Check if signed in via RSO
@@ -14,6 +30,7 @@ const RiotProfile = () => {
1430 }
1531
1632 setLoading ( false ) ;
33+ fetchData ( ) ;
1734 } , [ Auth ] )
1835
1936 if ( loading )
@@ -27,8 +44,8 @@ const RiotProfile = () => {
2744 < div className = { 'flex flex-row m-2 space-x-4' } >
2845 < img className = { 'rounded-full w-16 h-16' }
2946 src = { `https://ui-avatars.com/api/?background=random&color=fff&name=${ Auth ?. gameName } ` } />
30- < div > { 'overview ' } </ div >
31- < div > { 'matches' } </ div >
47+ < div > { 'Overview ' } </ div >
48+ < div > { 'Recent matches' } </ div >
3249 < div > { `info: ${ Auth ?. gameName } #${ Auth ?. tagLine } ${ Auth ?. puuid } ` } </ div >
3350 </ div >
3451 < div className = { 'animate-pulse' } >
0 commit comments