Im building a calendar with a synced todo list. I am trying to save a specific date based on the user input to local storage. At the moment the todo is saved to local storage and is presented in a todo list with text and in the calendar but if I refresh the page the todo in the calendar vanishes.
In local storage it's written value:[object HTMLInputElement]
function saveTodosToLS() {
const todosAsString = JSON.stringify(todos);
localStorage.setItem("todos", todosAsString);
}
function loadTodos() {
const todosAsString = localStorage.getItem('todos');
todos = JSON.parse(todosAsString || '[]');
}
This is the part Im struggling with
function saveCalendarToLS() {
const todoDateAsString = Date.parse('dateOfTodos');
todoDateAsString = JSON.stringify(dateOfTodos);
localStorage.setItem('dateOfTodos', todoDateAsString);
}
function loadTodosInLS() {
const todoDateAsString = localStorage.getItem('dateOfTodos');
dateOfTodos = Date.parse(todoDateAsString || '[]');
}