Premium Only Content

Using fetch to Retrieve Message Data for React App
The lecture goes over the use of fetch to retrieve data for the messages in a React application.
The Fetch API can be used to make an HTTP request to a backend server such as an API that serves data in the JSON format.
With a GET request, the default behavior of fetch, data for messages in a chat room-like user interface are retrieved.
The call to fetch returns a Promise that fulfills with a Response object.
You can extract the body of the response and interpret its text content as JSON, thus creating a JavaScript object with the mapped information. This is also known as deserialization or unmarshalling.
The json method of the response object can be called to extract the body of the response and read it as JSON, thus creating a JavaScript data structure with the data. In the example, it creates an array of objects.
Note the return value of the call to json is another Promise that fulfills with the deserialized value, so another call to then is necessary. Having multiple then statements in a row can be called a promise chain.
The map method of the array is used to transform it into another array with the relevant information.
The array of things that represent each message are then used to set the React state for messages.
-
53:38
Flyover Conservatives
14 hours agoAmerica's Near Death Experiences. The Times We Almost Lost Our Nation - Historian Bill Federer | FOC Special Show
26.1K4 -
44:25
The Mel K Show
3 hours agoMORNINGS WITH MEL K - Declaration of Independence 2025: Liberty, Freedom & Gratitude 7-4-25
25.4K22 -
40:29
The Tom Renz Show
2 hours ago4th of July Special - America's Independence
10.4K6 -
2:59:48
Wendy Bell Radio
10 hours agoGod Bless America
125K106 -
16:30
Dr Disrespect
1 day agoI Take One Vacation… and the Industry COLLAPSES
24.4K12 -
4:52
Talk Nerdy Sports - The Ultimate Sports Betting Podcast
3 hours agoFireworks & Fastballs: Riste’s 4th of July Lock Parade
15K1 -
1:13:15
Badlands Media
10 hours agoBadlands Daily: July 4, 2025
121K18 -
LIVE
GritsGG
5 hours agoWe Are Winning Every Game! Win Streaking! 👑 2998+ Ws
103 watching -
1:22:20
The Shannon Joy Show
16 hours ago🔥🔥Trump’s Big Brother Betrayal - The Final Strike on Freedom And a Gift to the Surveillance State | With Guest Aaron Day🔥🔥
10.3K7 -
35:42
Randi Hipper
5 hours agoBITCOIN ALL TIME HIGHS INCOMING! LEVELS TO WATCH
18.3K6