I am trying to send notification to the user when he/she gets a friend request.The problem I am facing is the server is sending the data but it is not able to be shown on the front end.
Here is the server side code
module.exports=function(io) {
io.on('connection',(socket)=>{
socket.on('joinRequest',(myRequest,callback)=>{
socket.join(myRequest.sender);
callback();
});
socket.on('friendRequest',(friend,callback)=>{
io.to(friend.receiver).emit('newFriendRequest',{
from:friend.sender,
to:friend.receiver
});
console.log('new friend request sent');
callback();
});
});
}
Here is the code on the client side
socket.on('newFriendRequest',function(friend){
console.log('heyy got you');
console.log(friend);
});