Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
26f7898a
Commit
26f7898a
authored
Jan 25, 2021
by
kusang96
Browse files
sda
parent
fa8802ee
Changes
3
Show whitespace changes
Inline
Side-by-side
client/src/Pages/ProductsList.js
View file @
26f7898a
...
@@ -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
)
...
...
server/controllers/product.controller.js
View file @
26f7898a
...
@@ -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
()
...
...
server/routes/category.routes.js
View file @
26f7898a
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment