title: how to save api data into a localstorage?
body: <p>I'm getting data from an API but i can't save my data into a localStorage. </p>
  
  <p>I've already tried a couple of things but i can't seem to find the problem. </p>
  
  <p><code>giveUsers();</code></p>
  
  <pre><code>function giveUsers() {
  
    for (let i = 0; i &lt; 10; i++) {
    fetch('https://randomuser.me/api/')
      .then(function (response) {
        return response.json();
    })
  
    .then(function (data) {
      showUsers(data.results);
    })
  
    .catch(function (error) {
      console.log("error", error);
    });
  
    let showUsers = (users) =&gt; {
        users.forEach(user =&gt; {
          // console.log(user.registered.age);
          // console.log(user.location.city);
          let firstName = user.name.first;
          let id = user.id;
  
          console.log(firstName);
          localStorage.setItem('allUsers', firstName);  
       });
    };}
  }
  
  
  if(localStorage.getItem('allUsers')){
    console.log(localStorage.getItem('allUsers'));
  }
  </code></pre>
  
  <p>I want my data into the localStorage.</p>