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:58:02
Barry Cunningham
9 hours agoJIMMY KIMMEL CANCELLED | OBAMA IS WHINING! | JD VANCE ON JESSE WATTERS!
110K131 -
2:34:46
TheSaltyCracker
8 hours agoWe Got Him Fired ReeEEStream 9-17-25
157K377 -
43:44
Man in America
10 hours agoAmericans Are About to Lose Everything—And They Don’t Even Know It
61.2K31 -
1:41:11
Adam Does Movies
2 days ago $3.58 earnedTalking Movies + Ask Me Anything - LIVE
46K2 -
3:40:08
I_Came_With_Fire_Podcast
16 hours agoNASA Blocks China, TPUSA BOOSTED, Chinese Spamoflauge, & Factional Division
44.8K6 -
33:40
Jamie Kennedy
9 hours agoEp 222 Processing the Loss of Charlie Kirk | HTBITY with Jamie Kennedy
64.5K28 -
1:32:05
Badlands Media
1 day agoAltered State S3 Ep. 46: Tactical Nukes, Thermite, and the 9/11 Puzzle
77K11 -
9:18
ARFCOM News
13 hours ago $2.00 earnedNSSF "Celebrates" ATF Partnership | Glocks BANNED | Redundant Spooky Boi Ban
40.4K10 -
13:09:13
LFA TV
22 hours agoLFA TV ALL DAY STREAM - WEDNESDAY 9/17/25
310K61 -
1:00:00
BEK TV
1 day agoAPRIL LUND: FAITH, FOCUS, AND THE ROAD TO THE 2028 OLYMPIC MARATHON
26.2K1