Javascript client for REST services, with promises