This Repo has complete code of my MERN stack series on YouTube https://www.youtube.com/playlist?list=PLB97yPrFwo5g0FQr4rqImKa55F_aPiQWk
instagram-clone-mern-stack's Introduction
instagram-clone-mern-stack's People
Forkers
viethien alabazatam ramirezramirez125 lokvora arjunumesh11 jmsandamil rampanchal8719 progzizo raloliver ashan-dev hunk7 sumitsojha88 lbaweja1999 trungnguyenbao ross-ferreira jamalapriadi ayeshaazam blueoceandevops hokivpn andreiturcanu aravinkrishna vmarpadge duncanwar pujithampalli aniket2107 vishaljkk sanchitamishra170676 gvbeema kyawmyohlaing ashish4913 rwik shubhampatelx64 slpriya 1518neil pradeeptakhatoi ranjanpandey2006 waseemwadea mohanraj11 hariharan228 xcodeworz marceluphd mohammedbakridev backbenchinnovations projectifyofficial ucheuzor bang25 shivam-skc vinay762 mariamatthew gitanamelek gabetech1 kmpr92 sachinkgp iftaqar shambashib20 abhijeet1995 bhcc-developer kasuengas bhavnakumrawat13 leidiflores jagtarsingh1232 kjschwoerke otienodominic gembaliamar sam92-coder kgaurav123 rupali1234880 rahul-das-sarma ted-cloud-beep 8504842010 sneshinde anexponent sandeep-07 zita1802 carlosa6 brillianttyagi khaledhelmyg himanshsingh0753 samm-26 nitiknarang77 kavyashree1903 rufai saifhany durgesh0187 snowpanther6 acenxion nrothgit skillsapphire shreya2221 kaoutartouiri surajrock406 arun27862786 destus-design abirelm sarkar10425 rkchintale vikhyathshetty365 ashwani361 varadjos89 oraldo-dociinstagram-clone-mern-stack's Issues
No error message is showing while creating a post without image.
ร Unhandled Rejection (TypeError): Cannot read property '_id' of null in home.js
Hello Sir,
Please I need help in home.js
My Code
import React, { useState, useEffect, useContext } from "react";
import { UserContext } from "../../App";
import {Link} from 'react-router-dom'
const Home = () => {
const [data, setData] = useState([]);
const { state, dispatch } = useContext(UserContext);
useEffect(() => {
fetch("/allpost", {
headers: {
Authorization: "Bearer " + localStorage.getItem("jwt"),
},
})
.then((res) => res.json())
.then((result) => {
console.log(result);
setData(result.posts);
});
}, []);
const likePost = (id) => {
fetch("/like", {
method: "put",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + localStorage.getItem("jwt"),
},
body: JSON.stringify({
postId: id,
}),
})
.then((res) => res.json())
.then((result) => {
//console.log(result);
const newData = data.map((item) => {
if (item._id == result._id) {
return result;
} else {
return item;
}
});
setData(newData);
})
.catch((err) => {
console.log(err);
});
};
const unlikePost = (id) => {
fetch("/unlike", {
method: "put",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + localStorage.getItem("jwt"),
},
body: JSON.stringify({
postId: id,
}),
})
.then((res) => res.json())
.then((result) => {
//console.log(result);
const newData = data.map((item) => {
if (item._id == result._id) {
return result;
} else {
return item;
}
});
setData(newData);
})
.catch((err) => {
console.log(err);
});
};
const makeComment = (text, postId) => {
fetch("/comment", {
method: "put",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + localStorage.getItem("jwt"),
},
body: JSON.stringify({
postId,
text,
}),
})
.then((res) => res.json())
.then((result) => {
console.log(result);
const newData = data.map((item) => {
if (item._id == result._id) {
return result;
} else {
return item;
}
});
setData(newData);
})
.catch((err) => {
console.log(err);
});
};
const deletePost = (postid) => {
fetch(/deletepost/${postid}
, {
method: "delete",
headers: {
Authorization: "Bearer " + localStorage.getItem("jwt"),
},
})
.then(res=>res.json())
.then(result=> {
console.log(result)
const newData = data.filter(item=>{
return item._id !==result._id
})
setData(newData)
});
};
return (
{data.map((item) => {
return (
<Link to={item.postedBy._id !== state._id ? "/profile/"+item.postedBy._id :"/profile" }>{item.postedBy.name} {item.postedBy._id == state._id
&& <i className="material-icons" style={{ float: "right" }}
onClick={()=>deletePost(item._id)}>delete
}
<i className="material-icons" style={{ color: "red" }}>
favorite
{item.likes.includes(state._id) ? (
<i
className="material-icons"
onClick={() => {
unlikePost(item._id);
}}
>
thumb_down
) : (
<i
className="material-icons"
onClick={() => {
likePost(item._id);
}}
>
thumb_up
)}
<h6>{item.likes.length} likes</h6>
<h6>{item.title}</h6>
<p>{item.body}</p>
{item.comments.map((record) => {
return (
<h6 key={record._id}>
<span style={{ fontWeight: "500" }}>
{record.postedBy.name}
</span>{" "}
{record.text}
</h6>
);
})}
<form
onSubmit={(e) => {
e.preventDefault();
makeComment(e.target[0].value, item._id);
}}
>
<input type="text" placeholder="Please Add a Comment" />
</form>
</div>
</div>
);
})}
</div>
);
};
export default Home;
issue while running the application
Proxy error: Could not proxy request /signup from localhost:3000 to http://localhost:5000/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
--please advise on this
Issue with the Login
Lession 40: TypeError: state.followers is undefined
Like/dislike makes the usernames above the comments disappear, along with who posted and the delete button
Please add all field
follow all of your code and still same problem. why its happening?
Button Loading
Hello, I have taken your course from udemy and stuck at a place so can you please help me out regarding this project please ?
sir where is readme file how to use it please expalin
After commenting on a post the comment line does not erase itself
TypeError
Failed to compile
hey,
Thanks for the tutorial on YT.
I'm facing an error called
"Failed to compile
./src/components/screens/signup.js
Line 35:11: Unexpected use of 'history' no-restricted-globals
Search for the keywords to learn more about each error."
can you help?
Profile Followers and Followings
The implementation doesn't work that you developed earlier for UserProfile. When you follow someone on the main page and look at then look at your profile it will show the count but if you go back one page you can again follow him!
Issue with follow/unfollow
I think the logic for follow and unfollow is incomplete as when we follow a user and then we refresh , we can follow that user again .
ACCORIDING TO ME WE CAN USE THIS LOGIC TO AVOID FOLLOWING THE SAME PERSON AGAIN AND AGAIN
useEffect(() => {
user &&
mainUser &&
(user.user.followers.includes(mainUser._id)
? setShowFollow(false)
: setShowFollow(true));
}, [user]);
Issue while deleting the comment
I was trying to create logic to delete the comments... the logic however working but there are some issues
node route to delete comment ==>
router.delete("/deletecomment/:id/:comment_id", requireLogin,(req,res)=>{ const comment ={_id:req.params.comment_id}; Post.findByIdAndUpdate( req.params.id,{ $pull:{comments:comment}, }, { new:true, } ) .populate("comments.postedBy","_id name") .populate("postedBy","_id name") .exec((err, postComment)=>{ if(err || !postComment){ return res.status(422).json({error:err}); } else{ const result=postComment; res.json(result) } }); })
**front end code **
const deleteComment =(postid,commentid)=>{ fetch(
/deletecomment/${postid}/${commentid}`,{
method:"delete",
headers:{
"Authorization":"Bearer "+localStorage.getItem("jwt")
},
}).then((res)=>{res.json()})
.then((result)=>{
const newData = data.map((item)=>{
if(item._id ==result._id){
return result
}
else{
return item
}
});
window.location.reload()
setData(newData);
window.location.reload()
})
}
// calling delete comment (Using material UI)
<span style={{fontWeight:"500"}}>{record.postedBy.name} {record.text}
{(item.postedBy._id || record.postedBy._id)== state._id &&
( <HighlightOffIcon onClick={()=>deleteComment(item._id,record._id)} style={{float:"right"}} /> )}
`
This works but requires refresh if I did not referesh it complains ......
Unhandled Rejection (TypeError): Cannot read property '_id' of undefined after refreshing page the comment gets deleted anyone knows better approach or solution to make this fixed
Facing issue in displaying small user profile picture in post header beside user name.
Hi,
I am facing a little issue and don't know how to solve it. I want to display the user profile picture in the post right beside the user name.
I write the state.pic
in the src image but it displays the profile picture of the current login user all over the posts.
Don't know how to solve it.help
my code
<div className='card-header'>
<div className='user-picandname'>
{}
<img className='user-profilepic' src={state ? state.pic : ""} />
<h5 className='user-title'>
<Link
to={
item.postedBy._id !== state._id
? "/profile/" + item.postedBy._id
: "/profile"
}
>
{item.postedBy.name}{" "}
</Link>
</h5>
</div>
{item.postedBy._id === state._id && (
<i
className='material-icons delete-icon'
onClick={() => {
deletepost(item._id);
}}
>
delete
</i>
)}
</div>
bcryptjs no longer using the same method as used in the course.
Regarding missing module
Cannot find module ./dev
property 'name' undefined
If I search another user from a profile page I just searched, it doesn't take me to his profile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.