Reputation: 2178
I am trying to use Chrome Dev for debugging the following Angular post request :
$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader)
After running the statement with right-click / evaluate, I can see the post in the network panel with a pending state. How can I get the result or "commit" the request and leave easily this "pending" state from the dev console ?
I am not yet very familiar with JS callbacks, some code is expected. Thanks.
EDIT
I have tried to run from the console :
$scope.$apply(function(){$http.post("http://picjboss.puma.lan:8880/fluxpousse/api/flow/createOrUpdateHeader", flowHeader).success(function(data){console.log("error "+data)}).error(function(data){console.log("error "+data)})})
It returns : undefined
EDIT
The error message returned is : JBoss Web/2.1.3.GA - Rapport d'erreur
type Rapport d'�tat
message
description La requ�te envoy�e par le client �tait syntaxiquement incorrecte ().
EDIT The post I am trying to solve generate an HTTP 400. Here is the result :
Upvotes: 0
Views: 2844
Reputation: 1550
Each $http request should have success and error callback like this:
$http({method: 'POST', url: '/someUrl'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Inside these methods you can debug in Dev Tools.
And if your request keeps pending, it might be something wrong with server side.
Note that if you don't have breakpoints making $http available (for example using Angular 1.2.6 in the chrome devtools) you can use:
angular.element(document).injector()
.get('$http')({method: 'POST', url: '/someUrl'})
.success(function(data, status, headers, config) {
console.log('$http-success:',arguments);
debugger;
})
.error(function(data, status, headers, config) {
console.log('$http-error:',arguments);
debugger;
});
Upvotes: 1