Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WYH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sangminLee
WYH
Commits
ac5636ad
Commit
ac5636ad
authored
4 years ago
by
epson220
Browse files
Options
Downloads
Patches
Plain Diff
searchBoardByKeyword
parent
c4b82889
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/routes/users.js
+16
-0
16 additions, 0 deletions
backend/routes/users.js
frontend/.eslintcache
+1
-1
1 addition, 1 deletion
frontend/.eslintcache
frontend/src/components/Board.js
+30
-5
30 additions, 5 deletions
frontend/src/components/Board.js
with
47 additions
and
6 deletions
backend/routes/users.js
+
16
−
0
View file @
ac5636ad
...
@@ -487,4 +487,20 @@ router.post("/profile", async function (req, res) {
...
@@ -487,4 +487,20 @@ router.post("/profile", async function (req, res) {
}
}
});
});
router
.
post
(
"
/searchBoard
"
,
async
function
(
req
,
res
)
{
console
.
log
(
"
/searchBoard post 요청
"
);
console
.
dir
(
req
.
body
);
try
{
let
searched
=
await
BoardModel
.
find
({
title
:
{
$regex
:
req
.
body
.
input
},
});
console
.
log
(
searched
);
res
.
send
(
searched
);
}
catch
(
err
)
{
console
.
log
(
err
);
}
});
module
.
exports
=
router
;
module
.
exports
=
router
;
This diff is collapsed.
Click to expand it.
frontend/.eslintcache
+
1
−
1
View file @
ac5636ad
This diff is collapsed.
Click to expand it.
frontend/src/components/Board.js
+
30
−
5
View file @
ac5636ad
...
@@ -4,6 +4,11 @@ import axios from "axios";
...
@@ -4,6 +4,11 @@ import axios from "axios";
const
Board
=
()
=>
{
const
Board
=
()
=>
{
const
[
response
,
setResponse
]
=
useState
([]);
const
[
response
,
setResponse
]
=
useState
([]);
const
[
input
,
setInput
]
=
useState
(
""
);
const
handleInputChange
=
(
e
)
=>
{
setInput
(
e
.
target
.
value
);
console
.
log
(
input
);
};
useEffect
(
async
()
=>
{
useEffect
(
async
()
=>
{
// try {
// try {
...
@@ -19,13 +24,27 @@ const Board = () => {
...
@@ -19,13 +24,27 @@ const Board = () => {
// }
// }
async
function
fetchData
()
{
async
function
fetchData
()
{
console
.
log
(
"
react board get axios 호출
"
);
console
.
log
(
"
react board get axios 호출
"
);
const
result
=
await
axios
.
get
(
"
http://localhost:3001/board
"
);
const
result
=
await
axios
.
get
(
"
http://localhost:3001/board
"
,
{
input
:
input
,
});
console
.
log
(
result
.
data
);
console
.
log
(
result
.
data
);
setResponse
(
result
.
data
);
setResponse
(
result
.
data
);
}
}
fetchData
();
fetchData
();
},
[]);
},
[]);
const
handleOnSubmit
=
()
=>
{
async
function
fetchData2
()
{
console
.
log
(
"
react board search axios 호출
"
);
const
result2
=
await
axios
.
post
(
"
http://localhost:3001/searchBoard
"
,
{
input
:
input
,
});
console
.
log
(
result2
.
data
);
setResponse
(
result2
.
data
);
}
fetchData2
();
};
return
(
return
(
<
div
>
<
div
>
<
button
>
<
button
>
...
@@ -34,10 +53,16 @@ const Board = () => {
...
@@ -34,10 +53,16 @@ const Board = () => {
<
button
>
<
button
>
<
Link
to
=
"
/updateProf
"
>
프로필
작성
<
/Link
>
<
Link
to
=
"
/updateProf
"
>
프로필
작성
<
/Link
>
<
/button
>
<
/button
>
<
form
action
=
"
http://localhost:3001/searchBoard
"
method
=
"
post
"
>
<
input
type
=
"
text
"
name
=
"
searchKeyword
"
><
/input
>
<
input
<
button
type
=
"
submit
"
>
게시글검색
<
/button
>
type
=
"
text
"
<
/form
>
//name="searchKeyword"
onChange
=
{
handleInputChange
}
><
/input
>
<
button
type
=
"
submit
"
onClick
=
{
handleOnSubmit
}
>
게시글검색
<
/button
>
<
ol
>
<
ol
>
{
response
.
map
((
res
)
=>
(
{
response
.
map
((
res
)
=>
(
<
li
key
=
{
res
.
_id
}
>
<
li
key
=
{
res
.
_id
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment