Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

HTTP call done twice #44

Open
gorghoa opened this issue Jun 22, 2016 · 6 comments
Open

HTTP call done twice #44

gorghoa opened this issue Jun 22, 2016 · 6 comments
Labels

Comments

@gorghoa
Copy link

gorghoa commented Jun 22, 2016

The APIService::getCollectionByUrl() trigger the http call twice (to be clear, I’m not talking about the OPTIONS http method here). This is due to the query.subscribe used to handle an error.

https://github.com/coopTilleuls/hm-admin/blob/master/src/app/hm-admin/services/api/api.service.ts#L36

My opinion is we should not interfere with the Rxjs observable error workflow and let the error live is nasty little life until someone who knows how to handle it catch it up.

Still in my opinion and arguably, the error should almost never be catched by the APIService. The error should bubble up to the final subscriber.

Anyhow, I bet that the error workflow is broken here since the exception is thrown asynchronuously and therefore is hardly catchable.

In case that my point was not clear: My fix proposition is to remove this subscription purely and simply ;)

@gorghoa gorghoa added the bug label Jun 22, 2016
@Gregcop1
Copy link
Contributor

Let the component handle the error on their own is pain in the ass IMO, but I think a share operator should solve the problem (to share the last result without rebuild the whole process on each subscribe)

@gorghoa
Copy link
Author

gorghoa commented Jun 22, 2016

Anyhow, who is responsible for catching your exception today? And (genuinely) how is the exception catchable? given the asynchronous stuff.

@Gregcop1
Copy link
Contributor

IMO, it should be the service

@Simperfit
Copy link
Contributor

This exception is wrong anyway :

  • Using angular2-jwt : when there are no jwt token, I get this exception instead of the one throw by angular2-jwt.

@Gregcop1
Copy link
Contributor

OK.
So for you two, what is the best ? Be able to have raise both exception (maybe only take care of 404 in service) or catching the same error on each component that can't reach the API ?

@Simperfit
Copy link
Contributor

Simperfit commented Jun 26, 2016

I would like to see both exception, catch any of them before the call and then catch this one if there is a problem without making two calls ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants