I am a newbie at using es6 js, using babel, axios and es6 trying to login user and get a response from a PHP file and all I need is return the response pass it to a callback function. When login is a console logged I get undefined but I want to get access to the data returned just for references.
account.js
export class Account{
constructor(){
}
methodGet(method,url,inputData,callback){
axios({
method:method,
url:url,
data: {
logindata: inputData
}
})
.then(response=>{callback(response)});
}
login(formdata){
this.methodGet('get','user/logs/login.php',formdata,function (params) {
let dataParam = params.data;
return dataParam;
});
}
}
app.js
import { Account } from "./classes/account.js";
let account = new Account();
let form = document.getElementById('form');
form.addEventListener('submit',event=>{
event.preventDefault();
let formdata = new FormData(this);
console.log(account.login(formdata));
},true);