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:20:39
Flyover Conservatives
15 hours agoFrom Demonic Deception to Divine Direction: Sid Roth’s Radical Encounter With God | FOC Show
40.9K1 -
DVR
Chrissie Mayr
3 hours agoChrissie Mayr Reactions to Charlie Kirk, Liberal Celebrations, and More
35.9K11 -
1:05:46
AlaskanBallistics
3 hours ago $0.79 earnedRemembering Charlie Kirk
38.2K6 -
1:23:27
Glenn Greenwald
6 hours agoNetanyahu’s Crude Exploitation of Charlie Kirk’s Death to Get the American Right Back into Line; Plus: Q&A With Glenn on Charlie Kirk's Assassination, Online Civil Discourse, and More | SYSTEM UPDATE #514
202K137 -
4:10:25
Nerdrotic
9 hours ago $1.04 earnedCulture Is VITAL! Streaming BUST, Warner Bros. Buyout | Friday Night Tights 371 with Vara Dark
213K27 -
1:02:32
BonginoReport
8 hours agoCharlie Kirk’s Assassin In Custody, Details Emerge - Nightly Scroll w/ Hayley Caronia (Ep.133)
196K202 -
LIVE
LFA TV
1 day agoKILLER CAUGHT LIVE PRESSER! - FRIDAY 9/12/25
607 watching -
26:08
The Mel K Show
7 hours agoMel K & Ken Silva | Updates: Trump Attempted Assassination Trial, North Carolina Investigation, & Silver Bump! | 9-12-25
51.3K5 -
1:24:33
Kim Iversen
8 hours agoBlaming Nick Fuentes For Charlie Kirk's Death In 3...2...1...
118K325 -
1:08:42
Roseanne Barr
11 hours agoFor Charlie…| The Roseanne Barr Podcast #115
217K229