Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const addTodo = (text, due) => {
if (!AV.User.current()) {
throw new Error('You have to login')
}
const Todos = AV.Object.extend('Todos')
const todo = new Todos()
todo.set('text', text)
todo.set('completed', false)
todo.set('due', due)
todo.set('owner', AV.User.current())
return todo.save()
}
return query.get(id).then(function (oldTodo) {
const updatedTodo = AV.Object.createWithoutData('Todos', id)
updatedTodo.set({
completed: oldTodo.attributes.completed,
text,
due: oldTodo.attributes.due
})
return updatedTodo.save()
}, function (error) {
throw new Error(error)