Answer the question
In order to leave comments, you need to log in
What's wrong with mongoose?
Several images are not loaded (one is normally loaded and saved) multer library
async create ({commit}, {title, text, price, category, categoryname, image, images}) {
try {
let imageFiles = []
for (let i = 0; i < images.length; i++) {
imageFiles.push(images[i].raw)
}
const fd = new FormData()
fd.append('title', title)
fd.append('text', text)
fd.append('price', price)
fd.append('category', category)
fd.append('categoryname', categoryname)
fd.append('image', image)
fd.append('images', imageFiles)
console.log(imageFiles)
// for(let i = 0; i < images.length; i++) {
// fd.append("images", images[i]);
// }
for (var pair of fd.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}
return await this.$axios.$post('/api/post/admin', fd)
} catch (e) {
commit('setError', e, {root: true})
throw e
}
},
// код роутера
router.post(
'/admin/',
passport.authenticate('jwt', {session: false}),
upload.single('image'),
upload.array('images'),
ctr.create
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question