title: Do you know how I can use async await withing a map function to change a variable in every loop?
body: <p>Do you know how I can make sure that the value of &quot;intentid&quot; change for every loop within the map function? The wanted result is that intentid changes its value for every loop, so that a new value is sent to &quot;someOtherAsyncApiFunction(someinnerfunction())&quot;. I need to use async/await, because &quot;intentid2&quot; calls an API.</p>
  <pre><code>let someobject = {1: {name: &quot;Question&quot;}, 2: {name: &quot;Tipp&quot;}, 3:{name: &quot;Question&quot;}}
  
  intentid = &quot;&quot;;
  
  const someFunction = () =&gt; {
    Object.keys(someobject).map(async (key,index) =&gt;{
      if (someobject[key].name === &quot;Question&quot;) {
        const someinnerfunction = () =&gt; {
          let followupintent = intentid;
          return followupintent
        }
        let intentid2 = await someOtherAsyncApiFunction(someinnerfunction())
    
        intentid = intentid2
        console.log(intentid)
      }}
      )
  }
  
  someFunction()
  </code></pre>