re: Day 17: I hate programming VIEW POST

re: I initially had a self invoking function to get habits from the database, loop through and display them on the web. I was trying to refactor that c...

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
// and another function to add a new habit on form submit
let addHabit = async function (event) {
// 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.

Code of Conduct Report abuse