pkozlowski-opensource / angularjs-mongolab

Resource-like factory for MongoLab based on $http and working with promises

Home Page:http://plnkr.co/edit/Bb8GSA?p=preview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error callback called on successfull write operations

hfinck opened this issue · comments

The $http service seems to interpret status code 201 (mongolab returns this) as an error. Every time I save a record both success and error callback are called.
I would suggest we handle the responses ourselves and then call the user's callback based on the status code.

Hmm, really strange, as this is $http that ultimately returns error codes and looking at its source code it should handle 201 just fine: https://github.com/angular/angular.js/blob/master/src/ng/http.js#L81

Could you try to prepare a reproduce scenario? The thing is that I'm using this code in my app and haven't seen any strange things going on around save...

@bluenavajo I think I know what is going on, someone had a very similar problem and asked me on the IRC. So, there was a bug in the documentation for the $saveOrUpdate method where the order of callbacks was not good (!). The actual code is alright, just docs were confusing people.

I've fixed this in 66eb8fc, please check on your side if this is the same issue.

Closing for now, please re-open if you still face problems. In this case please try to prepare a plunk with a reproduce scenario, I will look at this as a priority.