Learn how to build an HTTP web server in the Nodejs (Serverside Javascript) programming language with the ExpressJS library.
The lesson goes over generating an NPM project and installing express.
Then, you learn how to code a basic server running at a specific port on localhost.
You learn how to define endpoint routes and their handler functions.
You get exposed to the browser developer tools (DevTools) to monitor network requests so you can understand the request-response from the HTTP GET request made to the web server.
You also learn how to send back HTML to the client.
You learn how to change the status code of the response.
The lesson also shows how to use the static files middleware so you don't have to manually define a route for every asset file that you might have.
The lecture also briefly shows how to send back a JSON response to the client.
#expressjs
The lecture goes over an explanation of how chat room or board messages are retrieved for a React app.
It goes over the call to the fetch function that returns a Promise.
Then it goes over how the Promise returned by fetch gets fulfilled with a Response object.
The body of the response is extracted and turned into an array of objects in JavaScript.
A new array of strings is made after calling map on the array of message post objects.
Finally, the mutation function from React useState is called to signal React the state for messages has changed, triggering the rendering of the component anew.
#reactjs
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 ...
The lecture explores the callback passed to the useEffect hook in React.
It uses a setTimeout to demonstrate that initially the data is in its initial state, until it is changed by the corresponding mutate function.
Once mutated, the state change signals React to render the component anew, resolving DOM discrepancies, and manifesting the new data to the user.
In the example, an empty list of messages is populated after some brief period of time, a simulation of what's like to make a request to a backend server to retrieve data.
#reactjs