promises Flashcards

1
Q

What are the three states a Promise can be in?

A

pending - The initial state of a promise.
fulfilled - The state of a promise representing a successful operation.
rejected - The state of a promise representing a failed operation.

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

How do you handle the fulfillment of a Promise?

A

use the .then method and then you pass in an anonymous arrow functions

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

How do you handle the rejection of a Promise?

A

by calling the .catch( ) method, and take a function as its argument

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

What doesfetch()return?

A

it return a Promise

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
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
6
Q

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

A

add a second parameter with request method

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

When does React call a component’s componentDidMount method?

A

invoked immediately after a component is mounted or inserted into the tree. If you need to load data from a remote endpoint, this a good place to instantiate the network request.(after first successful render)

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

Name three React.Component lifecycle methods.

A

mounting, updating, unmounting

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

How do you pass data to a child component?

A

by using this.state.(__) in the parent component then this.prop.data in the child component

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