2

I'm attempting to make a Web 2.0 API call via AngularJS using $http.post that returns JSON and as weird as this may sound, it worked an hour ago, now it doesn't and I haven't changed a thing. The application continues to work in all other browsers, it just fails in Edge.

var _login = function (loginData) {
        var data = "";
        var grant = [insert data to authorise user on server];
        var deferred = $q.defer();
        $http.post(serviceBase + 'token', data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).success(function (response) {
            _userlogin(response);
            deferred.resolve(response);
        }).error(function (err, status) {
            console.log(err + " " + status);
            _logOut();
            deferred.reject(err);
        });
        return deferred.promise;
    };

I've had to take some info out there because it's security info, but the functionality should be the same, so, from debugging I know that this is where the application stumbles. I also know that the logindata passed in is valid and I've tried the same call with the same grant on a REST client and that works fine also like I mentioned before the same call with no alterations runs in any other major browser (including IE weirdly).

When that call is run, the front end angular does the following:

$scope.authUser = function (username, password) {
            var loginData = { userName: username, password: password, useRefreshTokens: login.useRefreshTokens}
            authService.login(loginData).then(function (response) {
                console.log(response);
                sessionStorage.setItem("status", "User Logged In As: ");
                sessionStorage.setItem("username", username);
                global.template = "templates/dashboard.html";
                login.password = "";
            },
            function (err) {
                console.log(err);
                login.message = err.error_description;
                $("#passwordError").modal();
            });
        };

The application stops at login.message = err.error_description;, because it's not returned from the API call. The error is: Network Error 0x2efd, Could not complete the operation due to error 00002efd. and Unable to get property 'error_description' of undefined or null reference.

Edit: Forgot to mention - the application works when Fiddler is open and capturing traffic. That's the strangest part.

Web Develop Wolf
  • 5,996
  • 12
  • 52
  • 101
  • Remove all the `console.log` from your code. Sometimes, it solves IE issues. – Mistalis Aug 02 '17 at 14:13
  • Nope still broken - two errors are: Unable to get property 'error_description' of undefined or null reference and Network Error 0x2efd, Could not complete the operation due to error 00002efd. – Web Develop Wolf Aug 02 '17 at 14:15
  • I am not sure but possibly problem connected with your headers. Just change them to application/json and check (to be sure that problem still here) In my apps http works fine for now. – Drag13 Aug 02 '17 at 14:20
  • Any strange network topography in the mix? Browser extensions? Have you tried incognito mode or whatever Edge's equivalent is? Really not sure what could be affecting it. – zero298 Aug 02 '17 at 14:20
  • Have you tried clearing the cache? We have had to add ```'If-Modified-Since': '0'``` to headers because Edge seems to want to rely on browser caching. – eczajk Aug 02 '17 at 14:24
  • Your code looks like you are sending the data as JSON and expecting JSON as a response. Why are you setting the header `'Content-Type': 'application/x-www-form-urlencoded'` ? – Igor Aug 02 '17 at 14:24
  • @Vitalii that's the header I'm passing but with the character encoding the Owin automatically adds – Web Develop Wolf Aug 02 '17 at 14:24
  • @zero298 - no strange typography just standard alphabet from a UK language config and the incognito mode throws the same problem – Web Develop Wolf Aug 02 '17 at 14:24
  • @WebDevelopWolf Sorry, **topography** as in, crazy network configurations between you and the server you are hitting. Like an SSO server or "interesting" reverse proxy server. – zero298 Aug 02 '17 at 14:26
  • @zero298 - Ahhh ok - nope nothing like that - just working off localhost to localhost – Web Develop Wolf Aug 02 '17 at 14:28
  • @eczajk - caching didn't solve the problem – Web Develop Wolf Aug 02 '17 at 14:32
  • 1
    Take a look at this [post](https://stackoverflow.com/questions/32581503/microsoft-edge-blocked-cross-domain-requests-sent-to-ips-in-same-private-network) which used the solution mentioned [here](https://stackoverflow.com/questions/32384571/why-does-microsoft-edge-open-some-local-websites-but-not-others-where-the-doma/32828629#32828629). They're saying the issue was with interacting between localhost to localhost. Hope that helps. – Mickers Aug 02 '17 at 14:41
  • I believe new angular versions use `.then()` and `.catch()` instead of `success()` and `error()` – Literally Illiterate Aug 02 '17 at 14:55
  • @LiterallyIlliterate - I don't get the error message about the undefined error but I do get the `Network Error 0x2efd, Could not complete the operation due to error 00002efd` error. – Web Develop Wolf Aug 02 '17 at 15:08
  • 1
    @Mickers - Thank you! That was the problem - at least now I know that I can test Edge when the application is published - If you throw that in as the answer I'll mark it off if you like for future reference – Web Develop Wolf Aug 03 '17 at 12:47

1 Answers1

1

Take a look at this post which used the solution mentioned here. They're saying the issue was with interacting between localhost to localhost.

I'm glad I was able to help.

Mickers
  • 1,367
  • 1
  • 20
  • 28