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 }) {
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
)
...
...
server/controllers/product.controller.js
View file @
26f7898a
...
...
@@ -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
()
...
...
server/routes/category.routes.js
View file @
26f7898a
...
...
@@ -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
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