product.controller.js 650 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Product from "../schemas/Product.js";

const regist = async (req, res) => {
    console.log('req.body=', req.body)
    const { pro_name, price, stock, main_category, sub_category, description, main_image, detail_image } = req.body.product
    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('죄송합니다. 다시 입력해 주십시오.')
    }
}

export default  { regist }