URL shortening site With HTML5/SCSS VANILLA JAVSCRIPT AND API

Solution retrospective
I could not get the URL stored in the local storage to load I kept getting errors
Any advice of how to solve this problem will be greatly welcome
-
Also I think my Javascript code is very disorganized and a bit difficult to read
-
I will appreciate tips for refactoring and best practices for writing clean Javascript code
-
Lastly, i added a delete button in form of an icon so the user can delete a url without having to refresh the page
Please log in to post a comment
Log in with GitHubCommunity feedback
- @jkellerman
I've had a quick look and checked the applications tab in chrome dev tools. The links are saving but not loading.
I would do something along the lines of:
- create a function that loads the todos.
E.g function loadTodos() {
const todos = localStorage.getItem(todos);
return JSON.parse(todosString) || [ ]; }
- create function that saves the todos
E.g function saveTodos() {
localStorage.setItem(todos, JSON.stringify(todos)); }
The loadTodos() function should run every time the page loads and saveTodos() should run whenever the user shortens a url.
Hope this helps! Happy coding
Marked as helpful
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord