Last active
February 15, 2020 04:50
-
-
Save HologramOfMe/1fea29a8ec106419f443deedd531bded to your computer and use it in GitHub Desktop.
Workflows for error handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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