So I have this call to an API in my actions at the Vuex Store, however I want to refactor it with a setTimeout, just to give my initial state time to commit(about a second). here's the function
Authenticate: ({commit})=>{
return new Promise((resolve) =>{
commit('auth_request')
return Axios.get(util.functions.pathFromScript('authenticate.php'),{params:params() }).then(resp =>{
state.logged_in = true
state.restricted =false
const data = resp.data
const session_id = data.session_id
console.log(session_id)
localStorage.setItem('data',data)
localStorage.setItem('session_id',session_id)
commit('auth_success', params, data,session_id)
resolve(resp)
})
})
}
so basically I can't figure it out where to add the async,and the timeout here. Any help would be appreciated A LOT! Thank you in advance