javascript - redux thunk doesn't wait for any promise
<p>I have an array like so</p>

<pre><code>array =[ {message:'http://about.com'}, {message:'http://facebook.com'}]
</code></pre>

<p>I want to loop that array, at each item I will make request to server to fetch opengraph data then save the data back to array. This what I expect</p>

<pre><code>array =[ 
    {
        message: { url:'http://about.com', title:'about'}
    }, 
    {
       message:{ url:'http://facebook.com', title:'facebook'}
    }
]
</code></pre>

<p>Then when it all finishes. I want to dispatch an action with payload is the expected array. Here is how I did it</p>

<pre><code>return dispatch =&gt; {

    let array =[ {message:'http://about.com'}, {message:'http://facebook.com'}]

    let quests = array
    .map( (item) =&gt; {
        axios.get(getOpenGraphOfThisLink + item.message)
        .then( result =&gt;{
            item.message = (result.data)
            return result
        })
    })

    Promise.all(quests).then( () =&gt; {
        console.log( 'modified', array)
        dispatch({
            type   : constant.GET_POST_COLLECTION_SUCCESS,
            payload: array
        })
        // this dispatch function sends my original array instead of modified one.
    })
}
</code></pre>

<p>The problem: the dispatch function in the code will send my original array to reducer instead of modified one. I want dispatch to send the new modified array. And I think it should it, shouldn't it?</p>