如何解决猫鼬的子架构子文档返回未定义的值
我的teamsSchema
是clientSchema
中的子架构。 teamName
的值始终返回undefined
,当从Chrome / React调用时,后端应用程序崩溃。
奇怪的是,在Postman中,teamName回来很好。但是在React中,它返回undefined-实际上使我的Express应用程序崩溃,因为teamName
是undefined
。我相信这是因为猫鼬模式现在允许它。
我的架构是否可以访问此架构?为何可以从Postman而不是Chrome / React中访问它?干杯
const teamsSchema = new mongoose.Schema({
teamName: {
type: String,},createdBy: {
type: String,teamMgrs:
{
type: Array,teamUsers:
{
type: Array,teamID: {
type: String,}
});
const clientSchema = new mongoose.Schema({
_id: {
// generated by UUID
type: String,teams: {
type: Array,ref: 'teamsSchema'
}
});
反应代码:
useEffect(() => {
axios
.post(
`${serverURL}/get-team-name`,{ teamID: editPrimaryTeam },{
withCredentials: true,credentials: 'include',}
).then(response => {console.log("teamname",response.data.teamName);}) },[])
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。