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.
-
22:25
DeVory Darkins
1 day ago $21.86 earnedTrump issues statement to the nation as FBI drops shocking update about shooter
99.1K143 -
10:55
Nate The Lawyer
2 days ago $2.11 earnedPortland's WOKE Laws Stop ALL Arrests to Help Illegal Migrants Fight ICE.
38.1K30 -
3:06:32
Price of Reason
16 hours agoCharlie Kirk Investigation Continues | Remembering 9-11 | Robert Downey Jr. Doctor Doom Look Reveal
281K71 -
2:12:26
Inverted World Live
12 hours agoManhunt for Suspect in Charlie Kirk's Assassination Continues, NASA Reveals "Life" on Mars | Ep. 107
264K58 -
2:44:02
TimcastIRL
13 hours agoMedia Warns Of Civil War Following Charlie Kirk Assassination | Timcast IRL
503K380 -
2:59:56
Laura Loomer
14 hours agoEP143: Remembering Charlie Kirk (1993–2025)
125K89 -
58:04
Man in America
17 hours agoCharlie Kirk’s Assassination—An URGENT WARNING for America
141K193 -
1:22:15
Glenn Greenwald
15 hours agoCharlie Kirk Assassination Fallout: U.S. Reps Call for Censorship; Do Graphic Videos Serve the Public Interest? Plus: WIRED Reporter on the Dark Side of Surrogacy | SYSTEM UPDATE #513
239K222 -
1:48:36
Right Side Broadcasting Network
21 hours agoLIVE: President Trump Attends the Yankees Baseball Game - 9/11/25
217K31 -
1:54:32
Badlands Media
15 hours agoBadlands Media Special Coverage - FBI Press Conference on Charlie Kirk's Assassination
176K22