Skip to content

Instantly share code, notes, and snippets.

@blogui91
Last active June 10, 2017 03:39
Show Gist options
  • Save blogui91/51fb13a051b903a4080d62e694faacb2 to your computer and use it in GitHub Desktop.
Save blogui91/51fb13a051b903a4080d62e694faacb2 to your computer and use it in GitHub Desktop.
import Service from 'easy-requests'
export class Client extends Service {
constructor() {
super();
}
static deactivate() {
let ClientService = new Client();
let route = ClientService.buildUrl('deactivate') //this line build our full route returning something like http://localhost:8000/clients/deactivate/
// basicly this is the structure that a promise instance must receive which it will be declared below.
let request = (resolve, reject) => {
//ClientService.http.{verb} Allow us to make the http request using the verbs [GET|POST|DELETE|PUT] etc
ClientService.http.get(route)
.then(response => resolve(response.data))
.catch(error => reject(error))
}
// Create a promise which will resolve our request ,
let request_promise = new Promise(request)
return request_promise;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment