Reputation: 3113
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);
}
Upvotes: 0
Views: 3594
Reputation: 2496
Try this
axios.delete("/task-asignee/" + props.userId, {
{ params: { task_id: props.taskId} ,
})
.then(res => {
props.onRemove();
})
.catch(err => console.log(err));
Upvotes: 2