Search code examples
angularjsdebuggingangular-promisees6-promise

Check data being returned in a .then AngularJS


I am trying to figure out the best way to check what is being returned to my response in my .then{}

for example can I add a console.log to the .then{} to see what is being returned if anything?

Below is my unsuccessful attempt at checking this data:

return myValidationService.getUserDetails(userId)
                        .then(response => response.data.data
                          //This is where I want to add my log
                          console.log("This is my response data: " + response.data.data))
                        .catch(error => pageErrorService.go(pageErrorService.errorDetails.genericError, error));

I am getting complaints from my linter about the above syntax though.

What is the standard way of checking this data?


Solution

  • In angular1.x it goes in this way:

    .then(function(response){
      console.log(response.data);
    })