async onSubmit() {
try {
const formData = {
category: "Карточка",
tags: this.tags,
title: this.title,
premium: this.checkbox,
averageRating: this.ratingFull,
rateOne: this.rateOne,
rateTwo: this.rateTwo,
rateTree: this.rateTree,
rateFour: this.rateFour,
rateFive: this.rateFive,
rateSix: this.rateSix,
nameCompany: this.nameCompany,
refLink: this.refLink,
videoLink: this.videoLink,
shortText: this.shortText,
specifications: this.specifications,
pros: this.pros,
htmlText: this.htmlText,
images: this.images,
imgVideo: this.imgVideo,
imgLogo: this.imgLogo,
procent: this.procent,
dayMin: this.dayMin,
dayMax: this.dayMax,
summaMin: this.summaMin,
summaMax: this.summaMax
};
const res = await this.$axios.$post(`api/card/admin`, formData);
alert(res.message);
} catch (err) {
alert(res.message, err);
}
},
data() {
return {
htmlText: ""
};
},
module.exports.updateCard = asyncHandler(async (req, res, next) => {
console.log(req.body.htmlText);
const card = await Card.findOneAndUpdate(
{
card: req.params.card
},
req.body,
{ new: true, runValidators: true }
);
if (!card) {
return next(
new ErrorResponse(`Not found with slug of ${req.params.card}`, 404)
);
}
res.status(200).json({ message: "Карточка успешно обновлена", data: card });
});