add envioment variables

This commit is contained in:
“Henry-Hiles” 2022-11-15 10:04:31 -05:00
parent 9bf8039422
commit 6646b17097
5 changed files with 30 additions and 22 deletions

1
.prettierignore Normal file
View file

@ -0,0 +1 @@
*.yml

View file

@ -1,5 +1,4 @@
import { useEffect, useState } from "react"
import config from "config"
import styles from "styles/Actor.module.css"
import { Link, useParams } from "react-router-dom"
import { GENRES } from "../constants"
@ -15,7 +14,9 @@ const Actor = () => {
useEffect(() => {
const run = async () => {
const response = await fetch(
`https://api.themoviedb.org/3/person/${actorId}?api_key=${config.apiKey}`
`https://api.themoviedb.org/3/person/${actorId}?api_key=${
import.meta.env.VITE_APIKEY
}`
)
const data = await response.json()
setActor(data)
@ -26,7 +27,9 @@ const Actor = () => {
useEffect(() => {
const run = async () => {
const response = await fetch(
`https://api.themoviedb.org/3/person/${actorId}/images?api_key=${config.apiKey}`
`https://api.themoviedb.org/3/person/${actorId}/images?api_key=${
import.meta.env.VITE_APIKEY
}`
)
const data = await response.json()
setImages(data)
@ -37,7 +40,9 @@ const Actor = () => {
useEffect(() => {
const run = async () => {
const response = await fetch(
`https://api.themoviedb.org/3/person/${actorId}/movie_credits?api_key=${config.apiKey}`
`https://api.themoviedb.org/3/person/${actorId}/movie_credits?api_key=${
import.meta.env.VITE_APIKEY
}`
)
const data = await response.json()
setCredits(

View file

@ -2,7 +2,6 @@ import TopBar from "components/TopBar"
import useDebounce from "hooks/useDebounce"
import { useEffect, useState } from "react"
import styles from "styles/Home.module.css"
import config from "config"
import Card from "components/Card"
const Home = () => {
@ -17,7 +16,7 @@ const Home = () => {
`https://api.themoviedb.org/3/${
debouncedSearch ? "search" : "discover"
}/movie?api_key=${
config.apiKey
import.meta.env.VITE_APIKEY
}&page=${page}&query=${encodeURIComponent(debouncedSearch)}`
)
const data = await response.json()

View file

@ -1,7 +1,6 @@
import { useEffect, useState } from "react"
import { Link, useParams } from "react-router-dom"
import styles from "styles/Movie.module.css"
import config from "config"
import useLocalStorage from "hooks/useLocalStorage"
import Rate from "components/Rate"
import TopBar from "components/TopBar"
@ -22,7 +21,9 @@ const Movie = () => {
useEffect(() => {
const run = async () => {
const response = await fetch(
`https://api.themoviedb.org/3/movie/${movieId}?api_key=${config.apiKey}`
`https://api.themoviedb.org/3/movie/${movieId}?api_key=${
import.meta.env.VITE_APIKEY
}`
)
const data = await response.json()
setMovie({
@ -47,7 +48,9 @@ const Movie = () => {
useEffect(() => {
const run = async () => {
const response = await fetch(
`https://api.themoviedb.org/3/movie/${movieId}/credits?api_key=${config.apiKey}`
`https://api.themoviedb.org/3/movie/${movieId}/credits?api_key=${
import.meta.env.VITE_APIKEY
}`
)
const data = await response.json()
setCast(data.cast)

View file

@ -1,16 +1,16 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import path from "path"
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
config: path.resolve(__dirname, "/src/config.json"),
styles: path.resolve(__dirname, "/src/styles"),
components: path.resolve(__dirname, "/src/components"),
hooks: path.resolve(__dirname, "/src/hooks"),
pages: path.resolve(__dirname, "/src/pages"),
plugins: [react()],
base: "./",
resolve: {
alias: {
styles: path.resolve(__dirname, "/src/styles"),
components: path.resolve(__dirname, "/src/components"),
hooks: path.resolve(__dirname, "/src/hooks"),
pages: path.resolve(__dirname, "/src/pages"),
},
},
},
});
})