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.
- 	
				
							LIVE
								SpartakusLIVE
8 hours agoSNIPING in Battlefield 6 - REDSEC || Monday MOTIVATION to CONQUER the Week
169 watching - 	
				
							49:25
								ThisIsDeLaCruz
4 hours ago $4.69 earnedBack Stage Pass with Avenged Sevenfold
31.3K7 - 	
				
							6:43:40
								GritsGG
9 hours agoWorld Record Win Streak Attempt! #1 Most Wins 3880+!
20.6K1 - 	
				
							3:12:05
								Tundra Tactical
6 hours ago $10.28 earnedProfessional Gun Nerd Plays Battlefield 6
51.6K5 - 	
				
							1:01:12
								Donald Trump Jr.
9 hours agoThe China Matrix with Journalist Lee Smith | TRIGGERED Ep.288
142K86 - 	
				
							11:56:00
								Dr Disrespect
14 hours ago🔴LIVE - DR DISRESPECT - ARC RAIDERS - FULL SEND INTO THE RED
157K18 - 	
				
							5:17:51
								JdaDelete
5 hours ago $0.35 earnedFinally playing Eldin Ring | First Playthrough Episode 2
9.82K2 - 	
				
							1:02:08
								BonginoReport
7 hours agoNicki Minaj Speaks Out Against Christian Persecution - Nightly Scroll w/ Hayley Caronia (Ep.169)
64.6K51 - 	
				
							5:23:36
								HomieQuest
7 hours agoLive Streaming! Pokemon Legends Z-A
4.82K4 - 	
				
							5:33:02
								FusedAegisTV
10 hours agoFUSEDAEGIS PLAYS THE GREATEST JRPG EVER MADE ⌛► CHRONO TRIGGER (1995) Part 3
4.08K2