2

I have a REST PHP API to get some data, and I use AngularJS $resource to gather them.

When a PHP Error occurs after a $save, the function called is not the error callback but the success callback, and the object become an array of chars with the PHP error. Since the object is actually destroyed that way, I loose the original data.

Is there a way to make $resource to see errors ?

2 Answers 2

1

On error, your API needs to return status other than 2xx. If you take a look at the source you may find that success callback will be called only if following condition is met:

200 <= status && status < 300
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I hadn't think to check the source.
1

You need to handle the error in PHP and return proper error code using php Use the header function to return error codes, like this:

header('HTTP/1.1 500 Internal Server Error');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.