Commit 4c9b09f6 authored by Aman Kumar Kesu's avatar Aman Kumar Kesu
Browse files

[ Search by get request]

parent 26df7c8c
......@@ -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.body.startDate);
var prevday= new Date(req.query.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);
}
});
});
......
......@@ -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]);
......
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