Is there a way to output JSON response that is coming from the server? I am trying the following, with undesirable output:
$http({ method: 'GET', url: 'getUser' })
.success(function (data,status) {
$scope.user = data;
console.log("User="+data);})
.error(function (data,status) {
$scope.status = status;
if(status==403)
$location.path( "/" );
});
Output:
User=[object Object]
log statements in your Angular application with calls to a service. Bring up an existing Angular application or create a new one. If you don't already have one, add a folder named shared under the \src\app folder. Create a new TypeScript file named log.
the console. It is used to debug an Angular application, identify performance issues, and troubleshoot problems with third-party libraries or other dependencies. We can access this function by opening the developer tools on any browser and navigating to the Console tab.
The json filter in AngularJs is used to convert a JavaScript object into a JSON. string. JavaScript object that we are using can be of any kind of JavaScript Object.
Definition and Usage. The json filter converts a JavaScript object into a JSON string. This filter can be useful when debugging your applications. The JavaScript object can be any kind of JavaScript object.
You can stringify
it before printing.
console.log("User = " + JSON.stringify(data));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With