Fetch Flashcards
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?
You pass it as one of the parameters when Fetch is being called.
ex.
fetch(resource, options)
resource
This defines the resource that you wish to fetch. This can either be:
A string or any other object with a stringifier — including a URL object — that provides the URL of the resource you want to fetch.
A Request object.
options Optional
An object containing any custom settings that you want to apply to the request. The possible options are:
method
The request method, e.g., GET, POST. Note that the Origin header is not set on Fetch requests with a method of HEAD or GET. (This behavior was corrected in Firefox 65 — see bug 1508661.)
When does React call a component’s componentDidMount method?
After the first successful render
see => https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
Name three React.Component lifecycle methods.
- componentDidMount()
- constructor()
- render()
How do you pass data to a child component?
You pass it as a prop