axios とPromise
イシュー
- axios で Promise を使うには
参考
- Promiseが分かれば簡単!async, await - Qiita
- [Firebase] HostingとCloud Functionsの連携方法あれこれ - Qiita
- How to do Axios request from Firebase Cloud Function - Stack Overflow
経緯
- 事の発端は、Firebase Functionで、axiosを使って、外部サイトをリクエストしたプログラムを書いている中で、以下のエラーが発生。
2019-08-02T19:55:05.561696851Z D proxy: Function execution started 2019-08-02T19:55:05.729Z E proxy: Unhandled rejection 2019-08-02T19:55:05.729Z E proxy: Error: connect ECONNREFUSED 127.0.0.1:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14) 2019-08-02T19:55:05.741424671Z D proxy: Function execution took 180 ms, finished with status: 'crash'
- javascript - Unhandled rejection from Cloud Function, but it runs sometimes - Stack Overflow によるとPromiseを返していないことが原因らしいが、そもそも同期処理したいのに、Promiseを返して大丈夫かがわからなかったので、Promise自体について動作を確認する。
- 僕なりのPromise入門 - Qiita
- reject はエラー状態