我试图在一列中创建一个用户,在另一列中创建sellerKeys
。我突突道:
验证错误:令牌验证失败:user:路径user
是必需的。
const createUser = async (userBody) => {
if (await User.isEmailTaken(userBody.email)) {
throw new ApiError(httpStatus.BAD_REQUEST, 'Email already taken');
}
// return User.create(userBody);
const createdUser = await User.create(userBody);
const sellerId = createdUser._id;
const user = createdUser.name;
console.log(user);
const sellerkeyBody = {
sellerId: sellerId, // Replace with the actual sellerId for the user
user: user,
shopify: {
isActive: false,
erp: {
isActive: false,
},
magento: {
isActive: false,
},
lazada: {
isActive: false,
},
shopee: {
isActive: false,
}
}
};
const createdSellerKey = await createSellerkey(sellerkeyBody);
await createdUser.save();
return { user: createdUser, sellerKey: createdSellerKey };
};
字符串
这是我的代码
1条答案
按热度按时间aurhwmvo1#
验证错误:令牌验证失败:user:路径
user
是必需的。此错误经常发生,因为您缺少一个强制值(该值不得为空)。在本例中,您试图创建一个
sellerKeys
实体,但没有为ORM提供用于创建的用户对象。