New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading indicator shown even when calls to API result in an error #21

Closed
zachberger opened this Issue Dec 28, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@zachberger
Contributor

zachberger commented Dec 28, 2016

Currently when the API errors out the loading indicator continues to be shown. It would be nice if the user got a friendly error message when the API is down.

screen shot 2016-12-27 at 11 33 00 pm

@housseindjirdeh

This comment has been minimized.

Show comment
Hide comment
@housseindjirdeh

housseindjirdeh Dec 28, 2016

Owner

Good call, it doesn't make sense to keep showing the loading indicators instead of a simple error message.

Owner

housseindjirdeh commented Dec 28, 2016

Good call, it doesn't make sense to keep showing the loading indicators instead of a simple error message.

@bfan1256

This comment has been minimized.

Show comment
Hide comment
@bfan1256

bfan1256 May 23, 2017

Just a question, what code are you checking on whether or not there is data from the cache and whether or not you are receiving data from an api? I'm sorry, I'm new to all of this pwa stuff and just wasn't sure on how you implemented this check.
Thanks and great tutorial!

bfan1256 commented May 23, 2017

Just a question, what code are you checking on whether or not there is data from the cache and whether or not you are receiving data from an api? I'm sorry, I'm new to all of this pwa stuff and just wasn't sure on how you implemented this check.
Thanks and great tutorial!

@housseindjirdeh

This comment has been minimized.

Show comment
Hide comment
@housseindjirdeh

housseindjirdeh May 23, 2017

Owner

@bfan1256 not at all! Please don't ever hesitate to ask questions. I'm glad you found my tutorial useful :)

So I specify a local errorMessage string in each of my main components. When I subscribe to the Observable responsible for returning data, I specify on the onError method to populate the errorMessage with a string.

Now in my template for the component, I use ngIf to show the loading indicator when there is no item and the error message field is blank. This scenario only passes if the request is still fetching. Similarly, I show the actual content only if the item object is populated.

Owner

housseindjirdeh commented May 23, 2017

@bfan1256 not at all! Please don't ever hesitate to ask questions. I'm glad you found my tutorial useful :)

So I specify a local errorMessage string in each of my main components. When I subscribe to the Observable responsible for returning data, I specify on the onError method to populate the errorMessage with a string.

Now in my template for the component, I use ngIf to show the loading indicator when there is no item and the error message field is blank. This scenario only passes if the request is still fetching. Similarly, I show the actual content only if the item object is populated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment