0

I have a controller method in my Spring Boot app which takes an argument from @RequestParam. I'm sending it using Axios, but every time the server responds with the following warning and the function doesn't get executed.

Required long parameter 'task_id' is not present]

axios request

axios.delete("/task-asignee/" + props.userId, null, {
     params: {
       task_id: props.taskId,
     },
   })
   .then(res => {
      props.onRemove();
    })
   .catch(err => console.log(err));

Spring boot controller method

@DeleteMapping("/task-asignee/{userId}")
public void removeTaskAssignee(@RequestParam("task_id") long taskId,@PathVariable long userId) {
    TaskAsigneeKey tak = new TaskAsigneeKey(userId,taskId);
    TaskAsignee ts = taskAsRepository.findById(tak);
    taskAsRepository.delete(ts);
}
Pavindu
  • 2,684
  • 6
  • 44
  • 77

1 Answers1

2

Try this

axios.delete("/task-asignee/" + props.userId, {
     { params: { task_id: props.taskId} ,
   })
   .then(res => {
      props.onRemove();
    })
   .catch(err => console.log(err));
A.khalifa
  • 2,366
  • 3
  • 27
  • 40