- Setup an API with a project structure like:
/client
--/server
----/routes
------index.js
------chirps.js
----server.js
----chirpsstore.js (file provided in this lab)- In
routes/chirps.js, createGET,POST,PUT,DELETEmethods on a router that is created inchirps.js.- Import
chirpsstore, and use it to read and write chirps to the json file.- The json file will be created the first time you run successfully!
- Remember to export your router with
module.exports.
- Import
- In
routes/index.js, import thechirpsrouter and add it to a new router.- Use
app.usewith the/chirpsroute to add to the rootapirouter. - Export the router.
- Use
- In
server.js, import the routes folder (./routes).- Add the
apirouter to the express app with the path/api.
- Add the
- Test all of your methods using Postman (https://www.getpostman.com/)
- Create an
index.html,styles.css, andapp.jsfile in theclientfolder.- Code an app that uses jQuery to call your API and displays chirps.
- Create a form that lets you create new chirps
- Do not use a form submit (you only need the inputs and not necessarily a form!)
- Use a button
clickevent to call the API.
- Add an
xnext to each chirp that will delete the chirp when clicked. - When a chirp is clicked, popup a modal that lets you edit the chirp.
- Create a form that lets you create new chirps
- Code an app that uses jQuery to call your API and displays chirps.
- Remember to use
express.staticmiddleware! - HINT: jQuery functions for calling APIs:
$.ajax,$.get,$.post