Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CRIO_BYTES
ME_NODEJS_MONGODB
Commits
4c9b09f6
Commit
4c9b09f6
authored
4 years ago
by
Aman Kumar Kesu
Browse files
Options
Download
Email Patches
Plain Diff
[ Search by get request]
parent
26df7c8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
Backend/routes/index.js
Backend/routes/index.js
+4
-6
Frontend/src/components/SearchForm.js
Frontend/src/components/SearchForm.js
+7
-1
No files found.
Backend/routes/index.js
View file @
4c9b09f6
...
...
@@ -69,12 +69,11 @@ router.get("/todos/endDate", (req,res) => {
curl -X "GET" -d 'name=Task-4 &startDate=2020-11-04&endDate=2020-11-21' http://localhost:3001/todos/search
*/
router
.
post
(
"
/todos/search
"
,(
req
,
res
)
=>
{
console
.
log
(
req
.
body
,
req
.
body
.
startDate
);
var
nextday
=
new
Date
(
req
.
body
.
endDate
);
router
.
get
(
"
/todos/search
"
,(
req
,
res
)
=>
{
var
nextday
=
new
Date
(
req
.
query
.
endDate
);
nextday
.
setTime
(
nextday
.
getTime
());
var
prevday
=
new
Date
(
req
.
bod
y
.
startDate
);
var
prevday
=
new
Date
(
req
.
quer
y
.
startDate
);
prevday
.
setTime
(
prevday
.
getTime
()
);
Todos
.
find
({
startDate
:{
...
...
@@ -88,7 +87,6 @@ router.post("/todos/search",(req,res)=>{
else
{
console
.
log
(
allTodos
);
res
.
json
(
allTodos
);
// res.send(allTodos);
}
});
});
...
...
This diff is collapsed.
Click to expand it.
Frontend/src/components/SearchForm.js
View file @
4c9b09f6
...
...
@@ -19,7 +19,13 @@ class SearchForm extends Component{
let
todoData
=
[];
let
task
=
this
.
state
;
axios
.
post
(
`http://localhost:3001/todos/search`
,
task
)
axios
.
get
(
`http://localhost:3001/todos/search`
,
{
params
:{
startDate
:
task
.
startDate
,
endDate
:
task
.
endDate
}
})
.
then
(
res
=>
{
for
(
let
i
=
0
;
i
<
res
.
data
.
length
;
i
++
)
{
todoData
.
push
(
res
.
data
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
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