Loading

Quipoin Menu

Learn • Practice • Grow

react / Fetch API in React
mcq
Direction: Choose the correct option

Q1.

How can you make an HTTP request in React using the Fetch API?
A. fetch(url).then(res => res.json())
B. $.ajax(url)
C. http.get(url)
D. axios.get(url)
Direction: Choose the correct option

Q2.

Where is the best place to fetch data in a functional component?
A. Inside useEffect with an empty dependency array
B. Inside the render
C. Inside useState
D. Inside useMemo
Direction: Choose the correct option

Q3.

How do you handle the response from fetch to get JSON data?
A. response.body
B. response.json()
C. response.data
D. response.text()
Direction: Choose the correct option

Q4.

What does the fetch function return?
A. A Promise that resolves to the Response object
B. An observable
C. The response data directly
D. A callback
Direction: Choose the correct option

Q5.

How do you set loading state while fetching data?
A. Fetch automatically handles loading
B. You don't need to
C. Use a boolean state that is true before fetch and false after
D. Use a loading component