add envioment variables
This commit is contained in:
parent
9bf8039422
commit
6646b17097
5 changed files with 30 additions and 22 deletions
1
.prettierignore
Normal file
1
.prettierignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.yml
|
|
@ -1,5 +1,4 @@
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import config from "config"
|
|
||||||
import styles from "styles/Actor.module.css"
|
import styles from "styles/Actor.module.css"
|
||||||
import { Link, useParams } from "react-router-dom"
|
import { Link, useParams } from "react-router-dom"
|
||||||
import { GENRES } from "../constants"
|
import { GENRES } from "../constants"
|
||||||
|
@ -15,7 +14,9 @@ const Actor = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const response = await fetch(
|
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()
|
const data = await response.json()
|
||||||
setActor(data)
|
setActor(data)
|
||||||
|
@ -26,7 +27,9 @@ const Actor = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const response = await fetch(
|
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()
|
const data = await response.json()
|
||||||
setImages(data)
|
setImages(data)
|
||||||
|
@ -37,7 +40,9 @@ const Actor = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const response = await fetch(
|
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()
|
const data = await response.json()
|
||||||
setCredits(
|
setCredits(
|
||||||
|
|
|
@ -2,7 +2,6 @@ import TopBar from "components/TopBar"
|
||||||
import useDebounce from "hooks/useDebounce"
|
import useDebounce from "hooks/useDebounce"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import styles from "styles/Home.module.css"
|
import styles from "styles/Home.module.css"
|
||||||
import config from "config"
|
|
||||||
import Card from "components/Card"
|
import Card from "components/Card"
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
|
@ -17,7 +16,7 @@ const Home = () => {
|
||||||
`https://api.themoviedb.org/3/${
|
`https://api.themoviedb.org/3/${
|
||||||
debouncedSearch ? "search" : "discover"
|
debouncedSearch ? "search" : "discover"
|
||||||
}/movie?api_key=${
|
}/movie?api_key=${
|
||||||
config.apiKey
|
import.meta.env.VITE_APIKEY
|
||||||
}&page=${page}&query=${encodeURIComponent(debouncedSearch)}`
|
}&page=${page}&query=${encodeURIComponent(debouncedSearch)}`
|
||||||
)
|
)
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import { Link, useParams } from "react-router-dom"
|
import { Link, useParams } from "react-router-dom"
|
||||||
import styles from "styles/Movie.module.css"
|
import styles from "styles/Movie.module.css"
|
||||||
import config from "config"
|
|
||||||
import useLocalStorage from "hooks/useLocalStorage"
|
import useLocalStorage from "hooks/useLocalStorage"
|
||||||
import Rate from "components/Rate"
|
import Rate from "components/Rate"
|
||||||
import TopBar from "components/TopBar"
|
import TopBar from "components/TopBar"
|
||||||
|
@ -22,7 +21,9 @@ const Movie = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const response = await fetch(
|
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()
|
const data = await response.json()
|
||||||
setMovie({
|
setMovie({
|
||||||
|
@ -47,7 +48,9 @@ const Movie = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const response = await fetch(
|
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()
|
const data = await response.json()
|
||||||
setCast(data.cast)
|
setCast(data.cast)
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite"
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react"
|
||||||
import path from "path";
|
import path from "path"
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
resolve: {
|
base: "./",
|
||||||
alias: {
|
resolve: {
|
||||||
config: path.resolve(__dirname, "/src/config.json"),
|
alias: {
|
||||||
styles: path.resolve(__dirname, "/src/styles"),
|
styles: path.resolve(__dirname, "/src/styles"),
|
||||||
components: path.resolve(__dirname, "/src/components"),
|
components: path.resolve(__dirname, "/src/components"),
|
||||||
hooks: path.resolve(__dirname, "/src/hooks"),
|
hooks: path.resolve(__dirname, "/src/hooks"),
|
||||||
pages: path.resolve(__dirname, "/src/pages"),
|
pages: path.resolve(__dirname, "/src/pages"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
});
|
|
||||||
|
|
Reference in a new issue