Hey Geekrumper!

This is a great question an, probably, deserves a entire post. Hopefully, I will find time soon to write one and explain everything in details 😊

But the short answer is that it’s all about provider. Instead of actual data, you inject axios instance into the service with the help of provider. And then service simply invokes axios methods. Consider this code:

First, we update the service interface. Since we are making API call, service methods become async.

Then we update Service to expect Axios instance to be injected at a construction time. And we use this instance to make actual calls.

Finally, we inject axios into the service in the provider.

Of course, there have to be many changes to be made. We would have to test the Service slightly differently, we would have to update everything that depends on the Service (the Store, in our case). But I hope you have a gist of the idea. Don’t hesitate to ask any questions

Written by

Software Engineer with about 15 years of experience in front- and back-end web development, and I know how to cook this dish!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store