Created
October 27, 2018 06:50
-
-
Save azaharafernandezguizan/7a25b49171fe02d0a1a0527d7dc4c92a to your computer and use it in GitHub Desktop.
Example of Aurelia Service connecting Web API
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 { 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