Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Http in the latest version of Angular and Ionic2 Alpha 46

$
0
0

@richardshergold wrote:

Does anyone know what has changed in the latest version of Angular with regards to http and/or the observable it returns? I've just upgraded my Ionic 2 app from alpha40 to alpha46 and the code below (which worked ok in 40) no longer works in 46. I get an error of "undefined is not a function near '.timeout(5000)'. I'm not sure what function the error is referring to. I tried removing the timeout line but that didn't fix it. I also removed the call to loginResult() and I still got the error. And I also removed the .map and that didn't fix it either. I'm a bit stumped!

login(credentials) {
   var username = credentials.username;
   var password = credentials.password;

   var parms = "Username=" + username + "&Password=" + password;
   this.http.post(MY_SERVER, parms, {
   headers:  { 'cache-control':'no-cache','Accept':'application/json','content-type':    'application/x-www-form-urlencoded' }
   })
   .timeout(5000)
   .map((res: Response) => res.text())
   .subscribe(
     res => this.loginResult(res),
     err => this.loginError(err),
     () => console.log('Login Complete')
    );
  }

   loginResult(res) {
     console.log('Login Result');
  }

  loginError(err) {
     console.log('Login Error');
  }

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles