Skip to content

Instantly share code, notes, and snippets.

@chovy chovy/webservice.js
Created May 21, 2015

What would you like to do?
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
You can’t perform that action at this time.