Fetch Flashcards

1
Q

What does fetch() return?

A

A Promise that resolves to a Response object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default request method used by fetch()?

A

GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

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.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When does React call a component’s componentDidMount method?

A

After the first successful render
see => https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name three React.Component lifecycle methods.

A
  1. componentDidMount()
  2. constructor()
  3. render()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you pass data to a child component?

A

You pass it as a prop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly