If the return value of a API request equals 401 then the user will be redirected to the login page. Using this method it's possible to decided within the API if a authentication is needed or not.