This weekend you are going to create an express app from scratch, whatever model you want.
Read this entire page before you start
- The app should have one model with at least two properties.
- It should have all the CRUD functionality.
- It should contain all the same RESTful routes we have in our fruits app.
- This app will be very similiar to the fruits app, but the model must be different.
- DO NOT COPY AND PASTE ANY CODE FROM YOUR FRUITS APP OR ANYWHERE ELSE. It's okay to use it as a reference, but type it out. DO NOT COPY AND PASTE.
- Do one small step at a time, and then make sure that one step works, and commit before moving on.
Remember: Use this list of RESTful routes as your guide for HTTP methods, CRUD functionalities, and URL formatting:
- Don't forget to
npm init
in order to start your node project. - If you get an error message that says module not found—did you install the module?
- READ YOUR ERROR MESSAGES, first try to solve them by going throught the error message, then look it up, then compare to code that you know works, like the fruits github repo, then ask a friend.
- Set up your db first and make sure it's connected.
- Do one route at a time, maybe start with your index route, then move onto creating a route
console.log()
everything you can think of.- Remember when you are submitting a form, you are making a request from the client, and your server has to respond to that request.
res.render
is for rendering templates (ejs),res.send
is for sending text. Remember, theres
object is how you 'respond' to the client.- Use lesson notes and labs from this week as a guide only if you are completely lost. But make sure you are giving it a true effort and not taking the easy way out. No Pain No Gain!