auth0-blog / angular2-authentication-sample

This is a sample that shows how to add authentication to an Angular 2 (ng2) app
MIT License
966 stars 334 forks source link

Update to Angular 2.0.0-alpha.30 #25

Closed NathanWalker closed 9 years ago

mgonto commented 9 years ago

Thanks :).

PatrickJS commented 9 years ago

you can replace fetch with Http now that the headers work

mgonto commented 9 years ago

Yep. I will. Thanks @gdi2290

PatrickJS commented 9 years ago

for example

    window.fetch(url, {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': 'bearer ' + this.jwt
      }
    })
    .then(status)
    .then(text)
    .then((response) => {
      this.response = response;
    })
    .catch((error) => {
      this.response = error.message;
    });
    http.get(url, {
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': 'bearer ' + this.jwt
      }
    })
    .toRx()
    .map(status)
    .map(text)
    .subscribe(
      response => {
        this.response = response;
      },
      error => {
        this.response = error.message;
      }
    )
NathanWalker commented 9 years ago

Oh thanks @ctindel, I think we do need to do that right @mgonto?

mgonto commented 9 years ago

Yep we do :).