app.post("/api/v1/content", middleware, async (req:Request, res:Response) => {
const {link,type,tags =[]}:ContentRequestBody =req.body;
try{
//@ts-ignore
const userId = req.userId;
const tagIds = await Promise.all(
tags.map(async (tag: string) => {
// Find or create the tag. If it doesn't exist, create it.
//@ts-ignore
const [tagRecord] = await tagsModel.findOrCreate({
where: { tag: tag }, // Look for the tag by name
defaults: { tag: tag } // If not found, create it with the tag name
});
return tagRecord.id; // Return the tag's ID (not name)
})
);
await contentModel.create({
link,
type,
//@ts-ignore
userId,
tags:tagIds,
});
return res.status(201).json({ message: 'Content created successfully' });
}catch (error) {
console.error('Error creating content:', error);
return res.status(500).json({ error: 'An error occurred while creating content' });
}
})
using ts express mongooes get isssue get map is not a function i want That user give us tag for storing the information and if the tag is saved in our database they can use it if does not user use it but that tag will store in our takeaways so future customers can use the same tag but I’m getting the issue on tagged map and I do not know what’s the issue I Google not but not getting the result please if anyone can help me
I am expected that my issue get resolved get to know what is the issue what that I make and how can I not repeat it A good description so I cannot do the same issue later