product.controller.js 609 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
    const { pro_name, price, stock, main_category, sub_category, description, main_image, detail_image } = req.body
Jiwon Yoon's avatar
Jiwon Yoon committed
6
7
8
9
10
11
12
13
14
15
16
    try {
        const newProduct = await new Product ({
            pro_name, price, stock, main_category, sub_category, description, main_image, detail_image
        }).save()
        res.json(newProduct)
    } catch (error) {
        console.log(error)
        res.status(500).send('죄송합니다. 다시 입력해 주십시오.')
    }
}

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