Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile posts not working #166

Open
Flexingcan opened this issue Nov 9, 2023 · 1 comment
Open

Profile posts not working #166

Flexingcan opened this issue Nov 9, 2023 · 1 comment

Comments

@Flexingcan
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants