Skip to content

Instantly share code, notes, and snippets.

@ralyodio
Created May 21, 2015 09:43
Show Gist options
  • Save ralyodio/c5bca147f37bab9bf341 to your computer and use it in GitHub Desktop.
Save ralyodio/c5bca147f37bab9bf341 to your computer and use it in GitHub Desktop.
Web service for aurelia.
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