Axios: Displaying errors in debug console

Created on 15 Oct 2016  路  1Comment  路  Source: axios/axios

When I do something like this in my code,

export function initUserFromStorage() {

  const request = axios.get("users/validate");

  return (dispatch) => {
    request.then(
      ({data}) => {
        let user = JSON.parse(localStorage.getItem("user"));
        dispatch({ type: TOKEN_VALID, payload: user });
      },
      (error) => {
        localStorage.removeItem("user");
        dispatch({ type: TOKEN_INVALID, payload: null });
      }
    )
  }
}

I get a "GET http://127.0.0.1:3000/api/users/validate 401 (Unauthorized)" displayed in my debug console. Is there anyway to hide that message? I'm catching the error so I thought nothing would be displayed.

Most helpful comment

Are you using Chrome? If yes, Chrome logs all network issues (including 4XX and 5XX errors) by default regardless of whether they are handled in the code or not. You can disable this behavior by checking "Hide network messages" checkbox in the Chrome DevTools settings (please see this for details).

Hope this helps!

>All comments

Are you using Chrome? If yes, Chrome logs all network issues (including 4XX and 5XX errors) by default regardless of whether they are handled in the code or not. You can disable this behavior by checking "Hide network messages" checkbox in the Chrome DevTools settings (please see this for details).

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdpagley picture jdpagley  路  3Comments

Baoyx007 picture Baoyx007  路  3Comments

tbaustin picture tbaustin  路  3Comments

achingbrain picture achingbrain  路  3Comments

ildella picture ildella  路  3Comments