0
votes

This is my home.jsx to fetch data token is taken from postman after logging in but it is giving error i have all the api data stored and package.json has a proxy address where api data is stored

import Navbar from '../../components/navbar/Navbar';
import './home.scss';
import Featured from '../../components/featured/Featured';
import List from '../../components/list/List';
import { useState } from 'react';
import { useEffect } from 'react';
import axios from 'axios'

const Home = ({ type }) => {
  const [lists, setLists] = useState([]);
  const [genre, setGenre] = useState(null);
  useEffect(() => {
    const getRandomLists = async () => {
      try {
        const res = await axios.get(
          `lists${type ? "?type=" + type : ""}${
            genre ? "&genre=" + genre : ""
          }`,
          {
            headers: {
              token:
              "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyZTEwYTA4ODA0MGEzNzdiYzlkMTkyOCIsImlzQWRtaW4iOnRydWUsImlhdCI6MTY1OTAwMTcxNCwiZXhwIjoxNjU5NDMzNzE0fQ.MrytFsoD201W4ehEVGmorUQzOxDmhLtEXrTQW4xM6N4",
            },
          }
        );
        setLists(res.data);
      } catch (err) {
        console.log(err);
      }
    };
    getRandomLists();
  }, [type, genre]);
  return (
    <div className='home'>
        <Navbar />
        <Featured type={type} />
        <List />
        <List />
        <List />
        <List />
    </div>
  )
}

export default Home