- Design and architect features across a frontend
- Integrate JavaScript and an external API
- Debug issues in small- to medium-sized projects
- Build and iterate on a project MVP
Welcome to the JavaScript Project!
You’ve worked so hard to get here and have learned a ton. Now it's time to bring it all together!
For this project, you're going build a Single Page Application (SPA).
Building this application will be challenging because it will integrate
everything you've learned up to this point. Your frontend will be built with
HTML, CSS, and JavaScript and will communicate with a json-server
mock backend.
-
Your app must be a HTML/CSS/JS frontend that accesses data from a mock backend served with
json-server
. All interactions between the client and the backend should be handled asynchronously and use JSON as the communication format. -
Your entire app must run on a single page. There should be NO redirects. In other words, your project will contain a single HTML file.
-
Use at least 1 unique [event-listener][] that enables interactivity. Think search or filter functionality, toggling dark/light mode, upvoting posts, etc.
-
Your project must implement at least one instance of array iteration using available array methods (
map
,forEach
,filter
, etc). Manipulating your backend data in some way should present an opportunity to implement your array iteration. -
Follow good coding practices. Keep your code DRY (Do not repeat yourself) by utilizing functions to abstract repetitive code.
If you achieve MVP early on and would like to give yourself a challenge, consider adding a stretch goal. Remember you only have a few hours to work on this project and be sure you have a completed MVP before attempting the following.
- Use a free public API in your project. If you choose to do so, we recommend avoiding API's that require a key or any sort of authorization. For ideas, see this list of no-auth APIs. If you would still like to use an API that requires a key, please consult with your instructor on how to protect that key. NEVER push your API key to github!
For this project, you will be given a local API served with json-server
to build
a frontend for. Your frontend should be built with HTML, CSS, and JavaScript and will
communicate with the given mock backend.
The project you will be building is an app for voting for the cutest animal. Use this gif as an example of how the app should work.
Your styling does not have to match what is shown in the above example. Feel free to add your own style!
When it comes to developing projects, a key concept to have in mind is the "Minimum Viable Product", or MVP for short. You should aim to meet the MVP requirements first. Doing so keeps your focus on completing a functional project first and foremost, avoiding any potential time loss on extraneous work.
For this project, those requirements are listed below as user stories:
As a user, I can:
- See each animal's name in a navigation bar.
- Click on each animal's name to display their vote count and photo.
- Click on a "Vote" button for a specific animal and immediately see their vote count increase.
- It should not affect the amount of votes any other animal has.
- For MVP, the update vote count does not need to persist once you refresh or navigate away from that animal.
To allow you to focus on writing code, we've provided you with some starter code and all the files you will need. Fork and clone down the attached repository to get started.
The three files you should be working in are:
index.html
style.css
src/index.js
The HTML file includes the boilerplate and links to both the CSS and JavaScript files.
We've also provided you with the mock database to work with. To get it started, use json-server
by running the following command:
json-server --watch db.json
Test your server by visiting this route in the browser:
Once that's up and running, you're good to start coding! Note that the base URL for your API will be http://localhost:3000.
The following deliverables are not required as part of this project's MVP and will not negatively affect your score if you do not attempt them. These are only here if you finish MVP early and want an extra challenge. Make sure you commit your work to save your progress before attempting the bonus deliverables!
As a user, I can:
- Click on a "Reset" button for a specific animal to reset their votes to 0.
- Extra challenge: Add a "Reset" button to reset all animal's votes to 0.
- Click on a "Vote" button for a specific animal and have the updated vote count persist.
- Hint: You will need to make a
PATCH
request to/animals/:id