TobiasLounsbury / EmpireSkillTest

0 stars 0 forks source link

Question: async/await #11

Open djfrailey opened 4 years ago

djfrailey commented 4 years ago

When axios returns a promise you're using the older style of .then and .catch whenever a promise is returned.

I'm curious to why you chose to use .then and .catch to handle resolved/rejected promises rather than the async/await syntax.

TobiasLounsbury commented 4 years ago

I'm equally comfortable with both patterns, and typically prefer to use async/await. This is my first use of Axios and the first google listing of usage employed the .then/.catch pattern and no further thought was given to it. If I had given it thought beyond is it working as expected, I would have chosen to go with async/await. Additionally if I had to do anything more complex than waiting for a simple data fetch it would have triggered a design consideration in my mind which would have again likely resulted in use of the alternate pattern.