1

In my AngularJS (1.5) app I am calling my backend endpoints with the $http service like this:

$http.post('url', _params).then(function (response) {

}).catch(function (error) {

});

Intermittently, my error coming back is null. There is no status or error code or anything like that. What could be the reason for that? I have a perfect Internet connection on the client computer.

Edit: The status code is actually -1. Here is an example of the response:

                "data": null,
                "status": -1,
                "config": {
                    "method": "POST",
                    "transformRequest": [
                        null
                    ],
                    "transformResponse": [
                        null
                    ],
                    "timeout": 8000,
                    "cache": false,
                    "url": "https://myurl",
                    "data": {
                        "username": "hello"
                    },
                    "headers": {
                        "Accept": "application/json, text/plain, */*",
                        "Content-Type": "application/json;charset=utf-8"
                    }
                },
                "statusText": ""
user1261710
  • 2,539
  • 5
  • 41
  • 72
  • 2
    Observe the network tab of your browser's developer tools. Ensure that the request is being made to the correct URL. – 31piy Dec 18 '17 at 10:46
  • It is intermittent though. Quite often it works and sometimes it doesn't. – user1261710 Dec 18 '17 at 10:47
  • 1
    Catch will "catch" errors in the promise. Error object could depend of your backend response – Zooly Dec 18 '17 at 10:50
  • 1
    how do you send your data back from your backend? – Aleksey Solovey Dec 18 '17 at 10:53
  • [`"status": -1` normally means that your backend is not available.](https://stackoverflow.com/questions/38882241/angular-http-requests-gives-1-status) Could be an [CORS allow-origin problem](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) – Aleksey Solovey Dec 18 '17 at 16:32

0 Answers0