Skip to content
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

Handling HTTP code 204 #13

Closed
rkusuma opened this issue Aug 28, 2015 · 8 comments
Closed

Handling HTTP code 204 #13

rkusuma opened this issue Aug 28, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@rkusuma
Copy link
Contributor

rkusuma commented Aug 28, 2015

Hi @guylabs

Somehow API will return 204 rather than 404 for unknown links.
How can i handle this 204 code ? Now when i get 204 all of request will be break and nothing happened.

Thanks

@guylabs guylabs added this to the 0.4.3 milestone Aug 28, 2015
@guylabs guylabs self-assigned this Aug 28, 2015
@guylabs
Copy link
Owner

guylabs commented Aug 28, 2015

Hi,

do you use Spring Data REST? If not I think I cannot give you support for that as this library is for Spring Data REST and the other usages are not supported and I think it is not a proper REST API if it returns a 204 instead of a 404.

You are able to implement your own fetchFunction (https://github.com/guylabs/angular-spring-data-rest#exchange-the-underlying-fetch-function) and then change this part here: https://github.com/guylabs/angular-spring-data-rest/blob/master/src/angular-spring-data-rest-provider.js#L105.

Then you can handle the 204 responses.

Thanks and regards,

Guy

@rkusuma
Copy link
Contributor Author

rkusuma commented Aug 28, 2015

Yes we use Spring Data REST.
Initialy we return 404.. but that's make log console browser full of 404 log, so we change to 204.

If i implement my own fetchFunction, i can't use your processData function.

@rkusuma
Copy link
Contributor Author

rkusuma commented Aug 28, 2015

@guylabs
What i want if there is 204 code, i want append that link to the data with null value.
The code is something like this:

if (responseData.status == 204) {
    return $injector.get("$q").when(data).then(function() {
        data[key] = null;
    });
}

and add it in https://github.com/guylabs/angular-spring-data-rest/blob/master/src/angular-spring-data-rest-provider.js#L93

What do you think ?

@guylabs
Copy link
Owner

guylabs commented Aug 28, 2015

Well in my opinion it is not a good idea to add this to the core as a 204 means something completely different and its not the standard how REST should be used.

And this is not Angular which logs them, but the browser itself, and therefore I wouldn't change the semantics of REST just to avoid these kind of logs. The normal users will never see these logs anyway. Here some links how to solve it in Chrome:

https://stackoverflow.com/questions/24207143/angular-avoid-console-trace-on-http-error
https://stackoverflow.com/questions/14337351/can-i-prevent-the-chrome-developer-tools-console-from-logging-image-404-errors/14427545#14427545

So therefore I would close this issue if it is ok with you.

Thanks and regards,

Guy

@rkusuma
Copy link
Contributor Author

rkusuma commented Aug 28, 2015

I see.. i'm ok with that..
last thing.. if i get 404 that means you skip that link?
For example:

SpringDataRestAdapter.process(response, ['link', 'link2', 'link3']).then(function(result) {
    ....
});

if link2 get 404.. result will only have link and link2 or skip all links?

@guylabs
Copy link
Owner

guylabs commented Aug 28, 2015

Well as you see it here: https://github.com/guylabs/angular-spring-data-rest/blob/master/src/angular-spring-data-rest-provider.js#L105

If one of those return a 404 then this link won't be fetched but the others will. So then I close the issue.

Thanks for using the component! :)

Regards,

Guy

@guylabs guylabs closed this as completed Aug 28, 2015
@rkusuma
Copy link
Contributor Author

rkusuma commented Aug 28, 2015

👍
I really like this angular-spring-data-rest. It helps me a lot.

Thanks Guy

@guylabs
Copy link
Owner

guylabs commented Aug 28, 2015

Thanks for the praise :).

Regards,

Guy

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

No branches or pull requests

2 participants