safak / youtube

5.04k stars 5.47k forks source link

Profile posts not working #166

Open Flexingcan opened 11 months ago

Flexingcan commented 11 months ago

I have tried changing the username to userId but the problem still arises everything is good everywhere else and i know this because i have deleted the code and it worked with any 404 errors. For clarification this part of lamadev's recat app project on his youtube channel

import "./feed.css";
import Share from "../share/Share";
import Post from "../post/Post";
import axios from "axios";
import { useEffect, useState } from "react";

export default function Feed(username) {
  const [posts, setPosts] = useState([]);

  useEffect(()=>{
    const fetchPosts = async () => {
      const res = username 
      ? await axios.get(`posts/profile/${username}`)
      : await axios.get("posts/timeline/6463c47ebc8a092b78e419c9");
      setPosts(res.data)
    };
  fetchPosts();
  },[]);

  return (
    <div className="feed">
        <div className="feedWrapper">
          <Share/>
          {posts.map((p) => (
          <Post key={p._id} post={p}/>
          ))}
        </div>
    </div>
  )
}

My main problem is the

useEffect(()=>{
    const fetchPosts = async () => {
      const res = username 
      ? await axios.get(`posts/profile/${username}`)
      : await axios.get("posts/timeline/6463c47ebc8a092b78e419c9");
      setPosts(res.data)
    };
  fetchPosts();
  },[]);

this code is supposed to show the posts of a profile on the profile page

everytime i use it i get inspect site command

hemanthmanu04 commented 8 months ago

Hey, I am facing the same issue. Did you find the solution for this issue?