This is a function for login I am getting the 'cannot read property rol of undefined' error: here is my vueJs code:
methods: {
send: function() {
this.error = null;
this.showLoader = true;
this.$http
.post("/login", new FormData(document.getElementById("LoginUser")), {
reponseType: "json"
})
.then(response =>
{
localStorage.setItem("role", response.data.data.rol);
location.href = "/";
},
fail => {
this.showLoader = false;
this.password = "";
for (let message of fail.data.data.messages) {
this.error = this.$t(
message.message.toLowerCase().replace(/ /g, "_")
);
}
}
);
}
}
what am i doing wrong? Thanks I have been trying to solve this for a long time but I have not succeeded
As per the documentation for vue-resource
, the response
object has no property data
. What you're looking for is either response.body
or response.json()
to resolve response.body
into a JSON object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.