Question: The full Error message is about this:

And here is the code I wrote using axios to consume the ny times API.

```js
export default function App() {
  const [info, setInfo] = useState([]);

  // Load dos dados da api
  useEffect(() => {
    async function loadNews() {
      const response = await api.get('/arts.json');

      const { results } = response.data;

      console.log(results);
      setInfo(results);
    }

    loadNews();
  }, []);

  return (
    <>
      <Main>
        <Title>Technology</Title>
        <Content>
          {info.map(news => <Text key={news.url}>{news.title}</Text> )}
        </Content>
        <Title>Science</Title>
      </Main>
    </>
  );
}

```

Is a better way of loading these json object. including maybe a pagination? Why is it giving me this error? should i use async functions outside useEffect hook but I dont know how

Answer: 
Each Fragment has an `onDestroy()` callback for when the fragment is popped off the back stack and destroyed. You can call your `stopPlayer()` from that method.

```
@Override
public void onDestroy() {
    super.onDestroy();
    stopPlayer();
}

```
Unfortunately, there is no direct way to do that Since the fragment doesn't have an `onBackPressed()` method, you will have to make a callback and implement it in the fragment to make it work.

First, you need to create an interface and class which implements its interface to have a generic method

1. Create class interface `OnBackPressedListener`

**OnBackPressedListener.java**

```java
public interface OnBackPressedListener {
    void goBack();
}

```

2. in your `MainActivity` Create the listener and make a setter for it and use it inside the `onBackPressed()` method after overriding it.

Your `MainActivity` should be something like this

**MainActivity.java**

```java
public class MainActivity extends AppCompatActivity {

    private OnBackPressedListener onBackPressedListener;

    public void setOnBackPressedListener(OnBackPressedListener onBackPressedListener) {
        this.onBackPressedListener = onBackPressedListener;
    }

    @Override
    public void onBackPressed() {
        if (onBackPressedListener != null){
            onBackPressedListener.goBack();
        }
        super.onBackPressed();
    }
}

```

3. In the `Fragment you should implement the` OnBackPressedListener` interface and use it to stop the player

**Fragment1.java**

```java
public class fragment1 extends Fragment implements OnBackPressedListener {

    @Override
    public void goBack() {
        stopPlayer();
    }
}

```

**Side note**

* Consider refactoring your `fragment1` name to be `Fragment1` with uppercased `F`