0

I am trying to redirect to another page after success callback but I am getting this error TypeError: Cannot read property 'push' of undefined

 this.http.post('http://localhost:3030/users', userDetails).subscribe(function 
 successCallback(response) {
  this.navCtrl.push(HomePage);
   }, function errorCallback(response) {
      // response with status 500
  }) ;
Chakri
  • 31
  • 4

1 Answers1

-1

Use arrow function => like this -

this.http.post('http://localhost:3030/users', userDetails).subscribe(successCallback(response) => {
  this.navCtrl.push(HomePage);
   }, errorCallback(response) => {
      // response with status 500
  }) ;
Pardeep Jain
  • 71,130
  • 29
  • 141
  • 199