Skip to content

Instantly share code, notes, and snippets.

@azaharafernandezguizan
Created October 27, 2018 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azaharafernandezguizan/7a25b49171fe02d0a1a0527d7dc4c92a to your computer and use it in GitHub Desktop.
Save azaharafernandezguizan/7a25b49171fe02d0a1a0527d7dc4c92a to your computer and use it in GitHub Desktop.
Example of Aurelia Service connecting Web API
import { IgNobel } from './../models/IgNobel';
import { inject, NewInstance } from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';
@inject(NewInstance.of(IgNobel))
export class IgNobelService {
private http: HttpClient = null;
public data : IgNobel[];
constructor() {
}
async getIgNobels(objectApp,callback) {
const response: Response = await fetch('http://localhost:5000/api/values/getIgNobels');
const json = await response.json();
objectApp.dataList = json;
callback(objectApp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment