I see that. I'm not sure that it is necessary to wrap the function as self executing. displayHabits 1. doesn't take any arguments when you define it but you are giving it an argument when you attempt to use it later in the code. 2. displayHabits fires itself first then returns itself to displayHabits.
I would simplify and make two functions
let displayInitialHabits = async function () {
// axios call to get saved habits and then display them
//
}
// then when document is loaded
displayInitialHabits();
// and another function to add a new habit on form submit
let addHabit = async function (event) {
event.preventDefault();
// get form data and save as a new habit
// clear form inputs after save
// add new habit to the list
}
I see that. I'm not sure that it is necessary to wrap the function as self executing. displayHabits 1. doesn't take any arguments when you define it but you are giving it an argument when you attempt to use it later in the code. 2. displayHabits fires itself first then returns itself to displayHabits.
I would simplify and make two functions
let displayInitialHabits = async function () {
// axios call to get saved habits and then display them
//
}
// then when document is loaded
displayInitialHabits();
// and another function to add a new habit on form submit
let addHabit = async function (event) {
event.preventDefault();
// get form data and save as a new habit
// clear form inputs after save
// add new habit to the list
}
Okay, I see why i'm getting the error. I'll refactor the code to follow a similar format.