Link:  http://blog.snap.hr/01/11/2018/vue-api-calls-smart-way/

Jorge Nieto wrote a nice article to demonstrate the Repository Factory pattern that exposes different ways to make calls to an API from Vue.js

vue api

Working demo

https://codesandbox.io/s/o93j2y4mj9