[buddypress-trac] [BuddyPress Trac] #8131: Make bp.apiRequest directly return the BP REST API error instead of the full xhr object.

buddypress-trac noreply at wordpress.org
Sun Sep 1 10:42:52 UTC 2019


#8131: Make bp.apiRequest directly return the BP REST API error instead of the
full xhr object.
-------------------------+-----------------------
 Reporter:  imath        |      Owner:  imath
     Type:  enhancement  |     Status:  assigned
 Priority:  normal       |  Milestone:  5.0.0
Component:  Core         |    Version:
 Severity:  normal       |   Keywords:  has-patch
-------------------------+-----------------------
 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 [https
 ://imath-buddydocs.pf1.wpserveur.net/bp-rest-api/ 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)

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8131>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list