Last active
June 10, 2017 03:39
-
-
Save blogui91/51fb13a051b903a4080d62e694faacb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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