How it works…

Axios will receive an error from example.com and this will trigger a rejection of the promise created when we called post. The rejection of a promise will, in turn, trigger the function passed inside the catch.

It's worth noting that at this point in the code, vm is referring to the root Vue instance; this is because the code is always executed after the Vue instance is initialized and assigned to vm.

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.