I am creating a todo list app using React and Python. But the update todo function is not working properly and gave me TypeError: Todo.put() got multiple values for argument 'todo_id'
.
@blp.arguments(TodoUpdateSchema)
@blp.response(200, TodoSchema)
def put(self, todo_id, todo_data):
todo = TodoModel.query.get(todo_id)
if todo:
todo.todo = todo_data["todo"]
todo.checked = todo_data["checked"]
else:
return {"message": "todo not found"}
db.session.add(todo)
db.sessionmit()
return todo
This is my Python handling method and from React I am sending:
export const updateTodo = async (id: number, editTodo: EditTodo) => {
const response = await axios.put(`${TODO_API_URL}/${id}`, editTodo);
return response.data;
};
It gave me a 422 HTTP status code. I have no idea how to fix it. Can anyone help me please?
class TodoSchema(Schema):
id = fields.Int(dump_only=True)
date = fields.Date(required=True)
todo = fields.Str(required=True)
checked = fields.Bool(required=False)
class TodoUpdateSchema(Schema):
class Meta:
unknown = EXCLUDE
todo = fields.Str(required=True)
checked = fields.Bool(required=True)
I kept changing the schema and parameter to send, but nothing is working.