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.
-
1:48:42
The Dan Bongino Show
4 hours agoThe Looming Threat That Nobody Is Talking About (Ep. 2445) - 02/04/2026
475K654 -
1:06:01
The Rubin Report
1 hour agoIlhan Omar Finally Got Scared After New Proof of Her $5M Winery Fraud Just Went Viral
5.03K21 -
LIVE
Trumpet Daily
2 hours agoGadi Taub Interview - Trumpet Daily LIVE | Feb. 4, 2026
227 watching -
LIVE
The Mel K Show
1 hour agoMORNINGS WITH MEL K - DC Reminds Americans They Don’t Work for US! 2-4-2026
573 watching -
DVR
Nick Freitas
2 hours agoHappening NOW: Virginia Democrats Say Screw You to Victims
20.3K2 -
LIVE
Nikko Ortiz
1 hour agoGround Branch Update... | Rumble LIVE
96 watching -
59:20
Benny Johnson
3 hours agoAlex Jones Blows the Doors Off The Epstein Files: ‘It’s all CIA. And He’s ALIVE…!?’
38.5K26 -
DVR
The State of Freedom
2 days agoWarrior Wednesday: Land. Ballots. Power. ⚔️
5.9K1 -
1:37:27
Graham Allen
3 hours agoPass The SAVE ACT NOW!! + Melinda Gates Confirms Epstein Files Are TRUE?!?
174K322 -
2:05:34
Badlands Media
2 hours agoBadlands Daily: 2/4/26
33.7K10