Firebase functions でエラーが発生したときに、
エラーの文言をフロント側に渡すことは可能でしょうか??
具体的には、
functionsの中で新規ユーザを作成し、
エラーが発生したらその文言をエラーメッセージとして表示したいです。
Firebase functionsの実行部
javascript
1exports.makeNewAccount = functions.https.onRequest((req, res) => { 2 3//正常パターン 4 }).catch(function(error) { 5//エラー時に文言を渡したい 6 return res.sendStatus(500).send('Unauthorized'); 7 });
↓フロントの呼び出し部
javascript
1 var getData = this.$http.get('https://hogehoge.cloudfunctions.net/makeNewAccount?hgoe=1').then(response => { 2 return response 3 }) 4 5 return Promise.all([getData.promise]).then(result => { 6 console.log('成功しました') 7 }).catch(function(error) { 8 console.log('失敗しました') 9 });
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/13 07:02