Skip to content

Commit b8bca2d

Browse files
committed
env var local
1 parent dad9fbe commit b8bca2d

File tree

9 files changed

+9
-56
lines changed

9 files changed

+9
-56
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ yarn-error.log*
3636

3737
# typescript
3838
*.tsbuildinfo
39+
40+
.vercel

components/Home/HomeComp.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ const HomeComp: React.FC <Props> = ({gameData, loading}) => {
6060
)
6161
}
6262

63-
// const getServerSideProps: GetServerSideProps = async()=>{
64-
// const res = await axios.get('')
65-
// }
6663

6764
export default HomeComp
6865

contexts/allGames.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

contexts/gameContext.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,6 @@ type Props = {
2323
export function GameProvider({children}: Props, { gameData }: any){
2424
console.log(gameData);
2525

26-
const getGames = async()=>{
27-
const options = {
28-
method: 'GET',
29-
url: 'https://free-to-play-games-database.p.rapidapi.com/api/games',
30-
headers: {
31-
'X-RapidAPI-Host': 'free-to-play-games-database.p.rapidapi.com',
32-
'X-RapidAPI-Key': 'bbce629d3cmsh48cb41094daa35cp1157cejsn05466969482c'
33-
}
34-
};
35-
const res = await Axios.request(options)
36-
console.log(res);
37-
return {
38-
props: {
39-
gameData: res.data
40-
},
41-
};
42-
};
4326

4427
return(
4528
<GameContext.Provider value={gameData}>

pages/game/[game].tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ const Game: NextPage = () => {
7676

7777
const getGame = async()=>{
7878
if (game!==undefined) {
79-
const res = await Axios.get(`https://api.rawg.io/api/games/${game}?key=a5c36a8abe0c4ddb9489dc567b3cf68d`)
79+
const res = await Axios.get(`https://api.rawg.io/api/games/${game}?key=${process.env.API_KEY}`)
8080
setGameDet(res.data)
8181
}
8282
}
8383
const getGameTrailers = async()=>{
8484
if (gameDetails!==undefined) {
85-
const res = await Axios.get(`https://api.rawg.io/api/games/${game}/movies?key=a5c36a8abe0c4ddb9489dc567b3cf68d`)
85+
const res = await Axios.get(`https://api.rawg.io/api/games/${game}/movies?key=${process.env.API_KEY}`)
8686
setGameTrailers(res.data.results)
8787
}
8888
}
@@ -104,7 +104,7 @@ const Game: NextPage = () => {
104104
params: {q: gameDetails.name+app},
105105
headers: {
106106
'X-RapidAPI-Host': 'bing-image-search1.p.rapidapi.com',
107-
'X-RapidAPI-Key': 'bbce629d3cmsh48cb41094daa35cp1157cejsn05466969482c'
107+
'X-RapidAPI-Key': `${process.env.RAPID_IM_KEY}`
108108
}
109109
};
110110
const res = await axios.request(options)

pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const Home: NextPage<Props> = ({gameData,isLoading, setIsLoading}: any) => {
4141

4242
export const getStaticProps: GetStaticProps = async()=>{
4343

44-
const res = await Axios.get('https://api.rawg.io/api/games?key=a5c36a8abe0c4ddb9489dc567b3cf68d')
44+
const res = await Axios.get(`https://api.rawg.io/api/games?key=${process.env.API_KEY}`)
4545
return {
4646
props: {
4747
gameData: res.data

pages/store/[page].tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Page = ({ gameData }: any) => {
4444
const getNextPageGames = async () => {
4545
setLoading(true)
4646
const res = await Axios.get(
47-
`https://api.rawg.io/api/games?key=a5c36a8abe0c4ddb9489dc567b3cf68d&page=${page}`
47+
`https://api.rawg.io/api/games?key=${process.env.API_KEY}&page=${page}`
4848
)
4949
console.log(res)
5050
setLoading(false)
@@ -94,14 +94,4 @@ const Page = ({ gameData }: any) => {
9494
)
9595
}
9696

97-
// export const getStaticProps: GetStaticProps = async()=>{
98-
99-
// const res = await Axios.get('https://api.rawg.io/api/games?key=a5c36a8abe0c4ddb9489dc567b3cf68d')
100-
// return {
101-
// props: {
102-
// gameData: res.data
103-
// },
104-
// };
105-
// };
106-
10797
export default Page

pages/store/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Store: NextPage = ({gameData}: any) => {
3737

3838
export const getServerSideProps: GetServerSideProps = async()=>{
3939

40-
const res = await Axios.get('https://api.rawg.io/api/games?key=a5c36a8abe0c4ddb9489dc567b3cf68d')
40+
const res = await Axios.get(`https://api.rawg.io/api/games?key=${process.env.API_KEY}`)
4141
return {
4242
props: {
4343
gameData: res.data

pages/store/search/[search].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const Search = () => {
2424

2525
const getSearchedItem = async()=>{
2626
setLoading(true)
27-
const res = await Axios.get(`https://api.rawg.io/api/games?key=a5c36a8abe0c4ddb9489dc567b3cf68d&search=${search}`)
27+
const res = await Axios.get(`https://api.rawg.io/api/games?key=${process.env.API_KEY}&search=${search}`)
2828
setSearchRes(res.data.results)
2929
setLoading(false)
3030
}

0 commit comments

Comments
 (0)