Commit 26f7898a authored by kusang96's avatar kusang96
Browse files

sda

parent fa8802ee
...@@ -33,30 +33,16 @@ function ProductsList({ match }) { ...@@ -33,30 +33,16 @@ function ProductsList({ match }) {
getProductlist() getProductlist()
}, [mainCategory]) }, [mainCategory])
async function handleClick(sub) {
console.log("sub=", sub)
try {
const response = await axios.get(`/api/product/getproduct/${mainCategory}/${sub}`)
console.log("response.data=", response.data)
setProductlist(response.data)
} catch (error) {
catchError(error, setError)
}
}
function handleChange(event) { function handleChange(event) {
console.log('handle change', event.target.value) console.log('handle change', event.target.value)
setSearch({ word: event.target.value }) setSearch({ word: event.target.value })
} }
async function handleSearch(event) { async function handleSearch(event) {
console.log('search', search)
event.preventDefault() event.preventDefault()
console.log("tlfgod")
try { try {
setError('') setError('')
const response = await axios.post(`/api/product/getproduct/${mainCategory}`, search) const response = await axios.post(`/api/product/getproduct/main/${mainCategory}`, search)
console.log("response.data=", response.data) console.log("response.data=", response.data)
setProductlist(response.data) setProductlist(response.data)
} catch (error) { } catch (error) {
...@@ -77,7 +63,7 @@ function ProductsList({ match }) { ...@@ -77,7 +63,7 @@ function ProductsList({ match }) {
async function getProductlist() { async function getProductlist() {
console.log("tlfgpd") console.log("tlfgpd")
try { try {
const response = await axios.get(`/api/product/getproduct/${mainCategory}`) const response = await axios.get(`/api/product/getproduct/main/${mainCategory}`)
setProductlist(response.data) setProductlist(response.data)
} catch (error) { } catch (error) {
catchError(error, setError) catchError(error, setError)
......
...@@ -70,12 +70,12 @@ const subname = async (req, res) => { ...@@ -70,12 +70,12 @@ const subname = async (req, res) => {
const categoryId = async (req, res, next, category) => { const categoryId = async (req, res, next, category) => {
const { search } = req.body const { search } = req.body
console.log("server=",search) console.log("server search=", search)
try { try {
const productslist = await Product.find({ main_category: category }) const productslist = await Product.find({ main_category: category })
if (!productslist) { // if (!productslist) {
res.status(404).send('상품을 찾을 수 없습니다.') // res.status(404).send('상품을 찾을 수 없습니다.')
} // }
req.productslist = productslist req.productslist = productslist
console.log("nononono", req.productslist) console.log("nononono", req.productslist)
next() next()
......
...@@ -6,7 +6,7 @@ const router = express.Router() ...@@ -6,7 +6,7 @@ const router = express.Router()
router.route('/main') router.route('/main')
.get(categoryCtrl.getCategory) .get(categoryCtrl.getCategory)
router.route('/sub/:name') router.route('/sub/:sub')
.get(categoryCtrl.getSubCategory) .get(categoryCtrl.getSubCategory)
export default router export default router
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment