Opened 5 years ago
Closed 5 years ago
#8131 closed enhancement (fixed)
Make bp.apiRequest directly return the BP REST API error instead of the full xhr object.
Reported by: | imath | Owned by: | imath |
---|---|---|---|
Milestone: | 5.0.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | has-patch |
Cc: |
Description
I've been testing the function we advise to use to do BP REST API requests in JavaScript a lot since I've checked every endpoints writing the BP REST API documentation.
Something always annoyed me: I had to get the xhr.responseJSON object to get the BP REST API error. I think using the attached patch will improve this by directly returning the BP REST API error for the generic way to deal with error (using the .fail()
callback).
I also think it's nice to have a default error in case something goes wrong and we haven't predicted it.
The patch is also improving how $.ajax
options are built in case the wp.apiRequest
is not available (WordPress 4.7 & 4.8)
In 12454: