Answer the question
In order to leave comments, you need to log in
How to work with cookies and database at the same time?
Good day.
Suppose the database stores tasks with a due date. You need to somehow (no matter how) mark these tasks in the database when the deadline has passed, i.e. when the task is overdue.
Without a database, I just did this (if this is not possible, then correct)
componentWillMount() {
setInterval(() => {
const newTodos = this.markExpiredTodos();
bake_cookie('todos', newTodos); // переписываем cookies
}, 10000);
}
markExpiredTodos() {
const allTodos = read_cookie('todos'); // получаем текущие данные из cookies
allTodos.forEach((todo) => {
// проверяем сроки и помечаем
});
return allTodos;
}
componentWillMount() {
this.props.fetchTodos();
this.interval = setInterval(() => {
const newTodos = this.markExpiredTodos();
this.props.saveTodos(newTodos); // отправляем запрос к БД вместо работы с cookies
}, 10000);
}
Answer the question
In order to leave comments, you need to log in
You are approaching the problem from the wrong side.
Write to the database timestamp deadLineDate , by the date of creation and determine the status.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question