rewrite API service with promises