Error Handling For Fetch() In Aurelia
I have an API that includes a useful description of what went wrong when an error is raised by the server (status = 500). The description comes as part of the response text. My cli
Solution 1:
This should do the trick:
functioncallRemoteService(apiName, timeout = 5000) {
returnPromise.race([
this.http.fetch(apiName)
.then(
r => r.json(),
r => r.text().then(text =>thrownewError(text))
),
this.waitForServer(timeout)
]);
}
by the way, I like what you're doing with Promise.race
- nice technique!
Post a Comment for "Error Handling For Fetch() In Aurelia"