product.controller.js 729 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
import Product from "../schemas/Product.js";

const regist = async (req, res) => {
    console.log('req.body=', req.body)
kusang96's avatar
kusang96 committed
5
6
7
    console.log('req.data=', req.data)
    console.log('req.body.data=', req.body.data)
    const { pro_name, price, stock, main_category, sub_category, description, main_image, detail_image } = req.body
Jiwon Yoon's avatar
Jiwon Yoon committed
8
9
10
11
12
13
14
15
16
17
18
19
    try {
        const newProduct = await new Product ({
            pro_name, price, stock, main_category, sub_category, description, main_image, detail_image
        }).save()
        console.log(newProduct)
        res.json(newProduct)
    } catch (error) {
        console.log(error)
        res.status(500).send('죄송합니다. 다시 입력해 주십시오.')
    }
}

kusang96's avatar
kusang96 committed
20
export default { regist }