How to get error message from auth attempt

I am building a vuejs application for the frontend & adonisjs for my backend, but when i send login request and it doesnt pass, i get errors from the network tab but i cant access this error messages in my vuejs application. code snippets below thanks.
the error message is returning back the status 500 but not the validation error that i see from the network tab.

async login({ request, auth }) {
		const { email, password } = request.all();
		const token = await auth.attempt(email, password);
		return token;
	loginUser({ commit, state }, payload) {
		commit('setLoginInputs', payload);
			.post('login', {
				email: state.loginEmail,
				password: state.loginPassword
			.then(({ data }) => {
			.catch(({ error }) => {
  1. Never use this error message again and the reason is that you can give the attacker to attempt to log in with another user but with the same password.
  2. Make sure that you’re not posting via jQuery or XHR. Chrome doesn’t allow you to do this is some cases.
  3. Run adonis with debugging command:

DEBUG=knex:* node app.js

  1. With this command, you can check all the errors and understand why 500 error is coming.

To understand the error 500 please check this link

1 Like

No, it does not. Query happens by uid configured in config/auth.js, email by default, no password is checked, if user is not found.

All decoupled server and client data transfer is done through XHR or Fetch. What are the cases where Chrome blocks it? Seems quite stupid of Chrome to block it. Since most web relies on those requests

This will only enable debug logging in underlying Knex

Coming back to your question @dropcode
You are destructing error out of failed request .catch(({ error }) => {
Try remove destructing and see what it logs then

.catch((error) => {

Also, what kind if library are you using? (What library is this HTTP)

1 Like

im using axios for sending request to my adonis backend, about the XHR part im guessing thats d default from axios, what should i use instead of xhr please any thoughts on this.

what else do u recommend i use to post if not XHR, i am using axios as my library to send request to my backend. if there is a way i can change it to use something more secured than XHR please ur thoughts.

Axios is good to use, no problem with it.

If you want to get error with it you need to get response out of error

.catch((error) => {
  console.log(error.response) // Error response from API
// Or
.catch(({ response }) => {
  console.log(response) // Error response from API
1 Like