Twitch project - additional functionalitites

Hi!

Link; https://codepen.io/rkosak/pen/wpZMLR?editors=0011

I have a problem with adding new functionalities to an app - Twitch Viewer.

  1. Sorting fetched data - I tried to sort result after getting data from API - but it works on 50%. Sometimes does, sometimes not. In the end, I want to put there an option to sort from a- z and z-a order.

  2. Filter - search method a few months ago I was training with Wes bos tutorial about using Fetch.
    In my app I cant get access outside .then, even if data is stored in the array - I cant do anything with it.

In this video, https://www.youtube.com/watch?v=y4gZMJKAeWs Wes uses .then only to fetch data into an array, and later on, uses functions to build functionalities.

Why doesn’t it work this way in my app?