i recieve some data from x API, but i am stuck between a rock, if i want to use 'states' variable into another function, for example i want to map json object like this :
of course, it shows me error, 'state is not define';
any short way to solve this problem?
//recieve data
window.onload =  async ()  => {
                const response = await fetch("x");
                const states = await response.json();
                 console.log(states);
             };
states.map(function(bra){
 // something
}
 
    