diff --git a/src/components/Card.jsx b/src/components/Card.jsx
new file mode 100644
index 0000000..245a292
--- /dev/null
+++ b/src/components/Card.jsx
@@ -0,0 +1,15 @@
+import React from "react";
+
+const Card = ({movie}) => {
+ const { Title, Year, imdbID, Poster } = movie
+ console.log("Card", Title, Year, imdbID, Poster)
+ return (
+
+
+
{Title}
+
{Year}
+
+ );
+};
+
+export default Card;
diff --git a/src/hooks/useFetch.jsx b/src/hooks/useFetch.jsx
index 5e5653c..a8f8036 100644
--- a/src/hooks/useFetch.jsx
+++ b/src/hooks/useFetch.jsx
@@ -1,16 +1,16 @@
import axios from "axios";
import { useState, useEffect } from "react";
-const useFetch = ({ url }) => {
+const useFetch = (url) => {
const [data, setData] = useState({});
- // const [error, setError] = useState("");
useEffect(() => {
+ // console.log("Inside fetch")
const fetch = async () => {
let response;
try {
- response = await axios.get(url);
- console.log("USEFETCH:",response)
- setData(response);
+ response = await axios.get(url);
+ // console.log("USEFETCH:", response?.data);
+ setData(response?.data);
} catch {
console.log("Error in useFetch: ");
return "Error Fetching Data";
@@ -21,6 +21,4 @@ const useFetch = ({ url }) => {
return data;
};
-
-
export default useFetch;
diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx
index b082f4d..1ff1706 100644
--- a/src/pages/HomePage.jsx
+++ b/src/pages/HomePage.jsx
@@ -1,16 +1,17 @@
import React, { useEffect, useState } from "react";
import useFetch from "../hooks/useFetch";
+import Card from "../components/Card";
+
const HomePage = () => {
- const [inputValue, setInputValue] = useState("")
- const [searchValue, setSearchValue] = useState("")
+ const [inputValue, setInputValue] = useState("");
+ const [searchValue, setSearchValue] = useState("");
+ const [data, setData] = useState("");
const url = import.meta.env.VITE_BASE_URL;
- console.log("URL =", `${url}s=${searchValue}`)
- const data = useFetch(`${url}s=${searchValue}`);
-
- // console.log("DATA = ", data)
-
+ const response = useFetch(url + "s=" + searchValue);
+ console.log(response)
+ useEffect(() => setData(response), [data]);
const handleSearch = (event) => {
event.preventDefault();
setSearchValue(inputValue);
@@ -24,14 +25,25 @@ const HomePage = () => {
name="search"
id="search"
value={inputValue}
- onChange={(event) => setInputValue(event?.target?.value)}
+ onChange={(event) =>
+ setInputValue(event?.target?.value)
+ }
className="p-1 text-quadnary bg-primary rounded outline-none border border-ternary"
/>
-