Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created July 3, 2018 06:46
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 dhavaln/be304db2c814a7d86dbf75229890d979 to your computer and use it in GitHub Desktop.
Save dhavaln/be304db2c814a7d86dbf75229890d979 to your computer and use it in GitHub Desktop.
App Component with API Call
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