Node.js 前端的Axios请求没有从后端的MongoDB数据库加载我需要的数据

Node.js 前端的Axios请求没有从后端的MongoDB数据库加载我需要的数据,node.js,reactjs,mongodb,express,axios,Node.js,Reactjs,Mongodb,Express,Axios,调用后端从mongoDB加载帖子。在邮递员公司工作。显示 前端上的自定义错误。我不明白为什么它不起作用。使用 Redux为axios调用加载用户信息 componentDidMount(){ 如果(!this.props.auth.isAuthenticated){ this.props.history.push('/'); } axios .get('http://localhost:5000/auth/loadUserPosts', { 名称:this.props.auth.user.nam

调用后端从mongoDB加载帖子。在邮递员公司工作。显示 前端上的自定义错误。我不明白为什么它不起作用。使用 Redux为axios调用加载用户信息

componentDidMount(){
如果(!this.props.auth.isAuthenticated){
this.props.history.push('/');
}
axios
.get('http://localhost:5000/auth/loadUserPosts', {
名称:this.props.auth.user.name
})
.then(res=>console.log(res))
.catch(err=>console.log(err));
}
路由器.get('/loadUserPosts',(req,res)=>{
const author=req.body.name;
Post.find({作者:作者})
。然后(posts=>{
//如果用户的帖子小于或等于零,则会出现“错误”消息
if(posts.length控制台.log(err));
});
把上面的改成这个

const author = req.query.name;

在《邮递员》中,你可能会进入body,但在axios中,你会进入
req.params

什么自定义错误?自定义错误不是正确的选择。我指的是没有帖子的回复。对此表示抱歉
const author = req.body.name;
const author = req.query.name;