@GerLC
Posted
Hola, como estas!
The problem with that, I think it is because of this: On this part $form.addEventListener when you do
-
validarForm();
-
guardarLS();
In validarForm() it might take a little time to fetch the data and push it in 'enlaces' in the guardarEnlace() function, so when guardarLS() fires you see that the first click on "shorten it" in the localStorage 'enlaces' is still empty [] so in mostrarDatos() when it try to get the data it wont get it at first. But after validarForm() finish it will push the link in 'enlaces', so if you click "shorten it" with nothing in the input a second time after the first one, it will load the information.
So what it is really happening, its that every time you click the "shorten it", the information gets delayed.
For solving this problem I would put guardarLS() inside validarForm() or in guardarEnlace() i think.
Marked as helpful