NOTE: This is a TWO-DAY project.
Day 1 Goals:
- demonstrate the use of the
.thenand.catchmethods - make
GETrequests to an external API usingaxios
Day 2 Goals:
- make
POSTrequests to an external API usingaxios - make
PUTrequests to an external API usingaxios - make
DELETErequests to an external API usingaxios
Resources Check in the notepad channel on slack for cohort specific resources like codesandbox links (e.g. #web19_notepad)
Helpful Links
- Run
yarn installornpm installinside of the root directory - Run
yarn startornpm startto start the API server - The provided server returns a list of friends when a
GETrequest is made tohttp://localhost:5000/friends. - In a separate terminal window, run
yarn create react-app friendsornpx create-react-app friendsto create your starter React application - CD into the new
friendsdirectory and runyarn add axios react-router-domornpm install --save axios react-router-domto include these dependencies in your project. You'll needreact-routerfor the stretch problems.
Day 1:
- Inside of your React application, implement a
GETrequest to retrieve a list of friends - Create a component to display the list of friends coming from the server
- Add a form component to gather information about a new
friend
Day 2:
- Add a button to save a new
friendby making aPOSTrequest to the same endpoint listed above - Each
friendshould have the properties listed below - Implement remove/delete functionality using a
DELETErequest - add a delete button or an x icon to each friend that will delete the friend when clicked. In the request url, pass the friend id as a URL parameter.
- Implement update/edit functionality using a
PUTrequest - pass the
friendidas a URL parameter, and the information you want to update about the friend inside of the body. You can build a new form in the UI for this, or, if you set it correctly, reuse the form you made for thePOSTrequest
friend properties for reference:
{
name: should be a string,
age: should be a number,
email: should be a string,
}API endpoints for reference:
GET /friends
POST /friends
PUT /friends/:id
DELETE /friends/:id- Separate the list of friends and the new friend form into different components, and use the appropriate React Router to build routes for the proper aspects of your components to be revealed separately.
- Style the friends list, the input field, and make everything look nice.
- Expand the number of properties that you put on each friend object.
- Feel free to remove the dummy data on the server or modify it in any way.