Created
May 21, 2015 09:43
-
-
Save ralyodio/c5bca147f37bab9bf341 to your computer and use it in GitHub Desktop.
Web service for aurelia.
This file contains hidden or 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 {inject} from 'aurelia-framework'; | |
import {Config} from '../config'; | |
import {HttpClient} from 'aurelia-http-client'; | |
@inject (Config, HttpClient) | |
export class WebService { | |
constructor (config, http) { | |
this.config = config; | |
this.http = http; | |
//this.http = http.configure(x => { | |
// x.withHeader('Content-Type', 'application/json'); | |
// x.withCredentials(true); | |
//}); | |
} | |
static sendRequest (method, path, request) { | |
if (request === undefined) request = null; | |
return this.http[method](this.config.serviceUrl + path, request); | |
} | |
getRequest (path, request){ | |
return this.sendRequest('get', path, request); | |
} | |
postRequest (path, request){ | |
return this.sendRequest('post', path, request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment