The defaults method in the request library is useful for creating a new request function with some options already set. It can also take a requester function, which is a lightweight way to extend functionality. The requester is undocumented but is at this point not much code to implement and could be an interesting refactor for xhr.