Answer the question
In order to leave comments, you need to log in
How to get value from an object?
Good day!
There is the following piece of code:
async create(req, res, next) {
try {
let {name, info} = req.body
const {img} = req.files
let fileName = uuid.v4() + ".jpg"
img.mv(path.resolve(__dirname, '..', 'static', fileName))
const brain = await Brain.create({name, img: fileName})
if (info) {
info = JSON.parse(info)
Object.keys(info).forEach(i => console.log(i))
// Object.keys(info).forEach(i =>
// Brain_info.create({
// title: i.title,
// description: i.description,
// brainId: brain.id
// })
// )
}
return res.json(brain)
} catch (e) {
next(ApiError.badRequest(e.message))
}
}
{
"title": "spad",
"description": "dsadsadsadsad"
}
console.log(i.title)
Answer the question
In order to leave comments, you need to log in
Identity verification does not depend on the design of the profile.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question