# Mutation Data error

**URL:** <https://forum.codewithmosh.com/t/mutation-data-error/23470>\
**Category:** React\
**Created:** [November 6, 2023, 12:17pm UTC](https://forum.codewithmosh.com/t/mutation-data-error/23470 "2023-11-06T12:17:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitris92](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dimitris92](https://forum.codewithmosh.com/u/Dimitris92)\
**Post date:** [November 6, 2023, 12:17pm UTC](https://forum.codewithmosh.com/t/mutation-data-error/23470/1 "2023-11-06T12:17:03Z")

</div>

For some reason the todo which i want to add don’ t work in todoForm  
i did the same thing that Mosh did

here is my code : const TodoForm = () =\> {  
const queryClient = useQueryClient();

const addTodo = useMutation\<Todo, Error, Todo\>({  
mutationFn: (todo: Todo) =\>  
axios  
.post(“[https://jsonplaceholder.typicode.com/todos](https://jsonplaceholder.typicode.com/todos)”, todo)  
.then((res) =\> res.data),

```
onSuccess: (savedTodo, newTodo) => {
  queryClient.setQueryData<Todo[]>(["todos"], (todos) => [
    savedTodo,
    ...(todos || []),
  ]);
},

```

});  
const ref = useRef(null)

 { event.preventDefault();

```
      if (ref.current && ref.current.value)
        addTodo.mutate({
          id: 0,
          title: ref.current?.value,
          completed: false,
          userId: 1,
        });
    }}

```

---

<div class="post-metadata">

**Author:** ![onlyhasbi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/onlyhasbi/32/4608_2.png) [@onlyhasbi](https://forum.codewithmosh.com/u/onlyhasbi)\
**Post date:** [November 9, 2023, 1:55pm UTC](https://forum.codewithmosh.com/t/mutation-data-error/23470/2 "2023-11-09T13:55:45Z")

</div>

Can you show me the error message and full code associated with the mutation?
