# Knowledge check: Interacting with the API

1. **Why should you never call hooks inside a nested function in react?**
    
    * <mark>Because hooks can only be called from the top level of a function component</mark>
        
    * To ensure that the component updates correctly
        
    * To avoid unnecessary re-renders of the component
        
    * To prevent memory leaks
        
2. **True or false. The fetch function should be used inside the** `componentDidMount` **lifecycle method or** `useEffect` **hook.**
    
    * <mark>True</mark>
        
    * False
        
3. **When you receive a HTTP response using the fetch() API, how do you parse the data into a JavaScript object?**
    
    * The `fetch()` API automatically parses the response data as a JSON object.
        
    * You should use the `text()` method of the response object to parse the data as a JSON object
        
    * <mark>You should use the </mark> `json()` <mark> method of the response object to parse the data as a JSON object.</mark>
        
    * You should use the `JSON.parse()` method to parse the response data as a JSON object.
        
4. **Which of the following statements are true? Choose all that apply.**
    
    * <mark>You can load local JSON files in your React project</mark>
        
    * The `fetch()` API call cannot make DELETE request
        
    * If the external API returns JSON data, you need to exclusively parse it in the `fetch()` API
        
    * You cannot make multiple `fetch()` calls in the `useEffect` hook
        
5. **Complete the sentence: JSON is \_\_\_\_\_\_\_\_\_\_\_\_\_\_.**
    
    * Only a data exchange format
        
    * Only a file format
        
    * <mark>A file format and a data exchange format</mark>
        

---

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728118369488/f315dd1e-b498-46bd-b4d2-5792c2ca78e9.png align="center")
