Skip to content

Instantly share code, notes, and snippets.

@HologramOfMe
Last active February 15, 2020 04:50
Show Gist options
  • Save HologramOfMe/1fea29a8ec106419f443deedd531bded to your computer and use it in GitHub Desktop.
Save HologramOfMe/1fea29a8ec106419f443deedd531bded to your computer and use it in GitHub Desktop.
Workflows for error handling
import { HttpClient } from '@angular/common/http';
import { Subject, Observable } from 'rxjs';
...
@Injectable({
providedIn: 'root'
})
export class HandService {
// Class Properties
randomProperty: boolean = false;
constructor(private http: HttpClient) { }
...
getStuffFromServer() {
this.http.get("http://sexytimes.com/api/bewbs", {type: "all"})
.subscribe(wholeLottaBewbs => {
// do something
...
return bestBewbs;
})
.then(bestBewbs => {
this.randomProperty = bestBewbs.bouncy;
})
.catch(err => {
console.log("All bewbs are temporarily hidden");
});
}
}
import { HttpClient } from '@angular/common/http';
import { Subject, Observable } from 'rxjs';
...
@Injectable({
providedIn: 'root'
})
export class HandService {
// Class Properties
randomProperty: boolean = false;
constructor(private http: HttpClient) { }
...
getStuffFromServer() {
this.http.get("http://sexytimes.com/api/bewbs", {type: "all"})
.subscribe(wholeLottaBewbs => {
// do something
...
const bestBewbs = wholeLottaBewbs[foundThem];
this.randomProperty = bestBewbs.bouncy;
},
(err) => {
console.log("All bewbs are temporarily hidden");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment