I have a function that calls a method that is in my Helper.js file.
import { getTest } from '../../common/Helper';
...
myMethod() {
   ...
   const test = getTest(this.state.myID);
   console.log(test);
}
...
My Helper.js:
export const getTest = (pID) => {
  axios.get('http://myserver.com/', {
    params: {
      method: 'getVacantUnits',
      propertyID: pID
    }
  }).then((response) => {
    console.log(response.data);
    return response.data;
  }).catch((error) => {
    // handle error
    console.log(error);
    return 0;
  });
};
It is odd because my output is:
undefined
myDataContent
It looks like that "const test" is receiving undefined before the getTest being run. Why is it happening?
Thanks
 
    