現在AWS Mobile HubでAmplifyを使用してモバイルアプリを開発していますが、
APIコールが成功しない状態です。
初期設定として「awsmobile configure」→「cloud logicの有効化」は行っており、AWSのGUI(WEB)からはAPIのテストコールも実施できています。しかしながら、Ionic3上でコールしようとすると失敗してしまいます。
Amplifyを使用してコールする正しい方法をご存知の方がいらっしゃいましたら、ご教示いただけますと幸いです。
よろしくお願いいたします。
javascript
1 2import Amplify, { API } from 'aws-amplify'; 3const aws_exports = require('../../aws-exports').default; 4Amplify.configure(aws_exports); 5 6/** 7 * Generated class for the ReceiptListPage page. 8 * 9 * See https://ionicframework.com/docs/components/#navigation for more info on 10 * Ionic pages and navigation. 11 */ 12 13@IonicPage() 14@Component({ 15 selector: 'page-receipt-list', 16 templateUrl: 'receipt-list.html', 17}) 18export class ReceiptListPage { 19 20 constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController) { 21 } 22 23 result: string; 24 25 ionViewDidLoad() { 26 console.log('ionViewDidLoad ReceiptListPage'); 27 /* 28 API.configure(options) 29 .then((result)=>{*/ 30 let apiName = 'getReceiptData'; 31 let path = '/items/'; 32 let myInit = { // OPTIONAL 33 headers: {}, // OPTIONAL 34 response: true // OPTIONAL (return entire response object instead of response.data) 35 } 36 console.log(API.get(apiName,path,myInit)); 37 API.get(apiName,path,myInit) 38 .then((result)=>{ 39 console.log(result); ⇦ここで失敗します 40 }); 41 //}); 42 43 } 44
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。