forked from CodeYourFuture/React-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
From React-Module-Project created by SallyMcGrath: CodeYourFuture#16
16. Load bookings remotely
Instructions:
Instead of getting the existing bookings from the file data/fakeBookings.json, we will get and load the bookings from a remote API. In the <Bookings /> component, use the React function useEffect to console.log() some text only when the page first renders on the screen. Verify that when you refresh the page, the text appears once in the console. Then, in the useEffect function, use the fetch() function to get data from https://cyf-react.glitch.me.
Try to pair or mob on this feature.
Hints:
- Replace
FakeBookingsin the bookings state and initialise it with[](because we haven't fetched any results yet!) - After calling the
fetch()function, use.then()to handle the response. Try looking at your Pokemon app that you worked on in class for an example - When the response comes back, use
setBookingsto update the results
Test:
- Verify the customers data are still displayed correctly in the table.
Metadata
Metadata
Assignees
Projects
Status
👀 In review