I have a requirement wherein I need to load the data through an ajax call to server and then pass on the data to reducer to render my page through props.
But I see the data in the ajax call is being shown as undefined.
function getInitData(url) {
    axios({url: url, timeout: 20000, method: 'get', responseType: 'json'})
    .then(function(response) {
        console.log(response.data.results)//--DATA DISPLAYED
        return response.data.results
    })
    .catch(function(response) {
        console.error(response.data);
    })
}
let formActions = {
    loadInitJSONSchema: function(formSchema) {
        let dataLoaded = getInitData('/startInterview')
        console.log(dataLoaded);//--DATA DISPLAYED as UNDEFINED
        return {type: 'LOAD_INIT_JSON_SCHEMA', formSchema: dataLoaded}
    }
}
I dont know why my data displayed as undefined in my actual method may be it is because of the asynchrnous call?? If so how do I load my data in actions??
Please find the complete code at the URL
 
    