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

sda

parent fa8802ee
......@@ -33,30 +33,16 @@ function ProductsList({ match }) {
getProductlist()
}, [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) {
console.log('handle change', event.target.value)
setSearch({ word: event.target.value })
}
async function handleSearch(event) {
console.log('search', search)
event.preventDefault()
console.log("tlfgod")
try {
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)
setProductlist(response.data)
} catch (error) {
......@@ -77,7 +63,7 @@ function ProductsList({ match }) {
async function getProductlist() {
console.log("tlfgpd")
try {
const response = await axios.get(`/api/product/getproduct/${mainCategory}`)
const response = await axios.get(`/api/product/getproduct/main/${mainCategory}`)
setProductlist(response.data)
} catch (error) {
catchError(error, setError)
......
......@@ -70,12 +70,12 @@ const subname = async (req, res) => {
const categoryId = async (req, res, next, category) => {
const { search } = req.body
console.log("server=",search)
console.log("server search=", search)
try {
const productslist = await Product.find({ main_category: category })
if (!productslist) {
res.status(404).send('상품을 찾을 수 없습니다.')
}
// if (!productslist) {
// res.status(404).send('상품을 찾을 수 없습니다.')
// }
req.productslist = productslist
console.log("nononono", req.productslist)
next()
......
......@@ -6,7 +6,7 @@ const router = express.Router()
router.route('/main')
.get(categoryCtrl.getCategory)
router.route('/sub/:name')
router.route('/sub/:sub')
.get(categoryCtrl.getSubCategory)
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