This project demonstrates a proof of concept for emulating a minimum API using HTML and JavaScript. It includes three HTML files that showcase how to store and retrieve data using localStorage, enabling communication between different pages on the same origin.
- addUser.html: A page where users can input a name to add to the user list. The entered names are stored in
localStorage. - viewUsers.html: A page that retrieves and displays the list of users stored in
localStorage. - APIUsers.html: A standalone version that mimics API-like functionality for adding and viewing users, all within a single HTML page.
- Data Storage: Uses
localStorageto persist user data across page reloads and between different HTML files. - User Management: Allows adding new users and viewing the existing user list.
- Minimal Setup: No backend server is required; everything runs client-side in the browser.
- Clone the Repository (if applicable) or create the HTML files as described above.
- Open the HTML files in your web browser:
- Open
addUser.htmlto add users. - Open
viewUsers.htmlto view the list of added users. - Open
APIUsers.htmlis a combination of the html listed above. I made this version first ^
- Open
-
To Add a User:
- Navigate to
addUser.html, enter a name in the input field, and click "Add User." The user will be stored inlocalStorage.
- Navigate to
-
To View Users:
- Navigate to
viewUsers.htmland click "Get Users" to see the list of all users added.
- Navigate to
-
Standalone Version:
- Use
APIUsers.htmlto manage users in a single page.
- Use
This project serves as an example of how to emulate API behavior using just HTML and JavaScript. It highlights the capability of localStorage for simple data persistence in a client-side environment.
This project is open source and available under the MIT License.