Created
July 3, 2018 06:46
-
-
Save dhavaln/be304db2c814a7d86dbf75229890d979 to your computer and use it in GitHub Desktop.
App Component with API Call
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 { Component } from '@angular/core'; | |
import Amplify, { API } from 'aws-amplify'; | |
import aws_exports from '../aws-exports'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
todos = []; | |
loading = false; | |
ngOnInit(){ | |
Amplify.configure(aws_exports); | |
this.loading = true; | |
API.get('sampleCloudApi', '/items', {}).then(data => { | |
this.loading = false; | |
this.todos = data; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment