0403 (express static, api reg etc., react routing etc.) Flashcards
What is the purpose of the Express Static middleware?
it serves static files
What does express.static() return?
it returns a middlewear
What are several examples of static files?
images, index.html, main.js, styles.css? files u just get and deliver as is.
extra:
non static files: sound files, files u need server for, files you import (you are running it)
What is a good way to serve application images using Express?
put them in an images folder inside (public)?
What does fetch() return?
A Promise that resolves to a Response object.
What is the default request method used by fetch()?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
How does fetch report errors?
fetch is a promise so it can do that
How can useEffect be used to load data for a component?
with fetch?
What browser function can be used to make HTTP requests to a server in React?
fetch
How do you use useEffect to load component data just once when the component mounts?
by using empty brackets (an empty array) as a dependency?, e.g. [ ]
How do you use useEffect to load component data every time the data key changes?
pass that key as a dependency in the array, [ ]
In a large-scale production app, what are some better alternatives for loading and managing backend data?
Some good open source packages are React Query and Vercel SWR work.
errors:
500s are?
400s are?
which is client/server?
500 server
400 client
What is the purpose of React “context”?
To be able to pass data from a (distant) parent to many children instead of manually passing props indiviaually
.