How to consume a Laravel API in a standalone Vue.js app
VueJs Consumer App – Laravel API with Passport
Hello everyone! Here I will show you how to consume a Laravel API with passport authentication in Vuejs app. In an earlier post, I have shown you how to integrate passport API into your Laravel apps. As a continuation, I will create a VueJs consumer app here in this tutorial.
Vuejs Consumer App – Create
Let’s create a new Vue standalone app using Vue CLI.
To use Vue CLI, first, we must have it installed in our system. If it is not already installed, just run the following command.
npm install -g @vue/cli
Now let’s create a new Vue app, run the following command.
vue create test-app
Install Axios for making API Calls
As I need to call the API here, I use Axios to do all HTTP requests and handle responses. So let us install it. Run the following command to install Axios.
npm install --save axios vue-axios
So after installing it, let us use it in our Vue app.
For full tutorial, please visit:
Post: https://justlaravel.com/vuejs-consumer-app-laravel-api-passport/
YouTube: https://www.youtube.com/watch?v=5W48kXdcvNs
GitHub: https://github.com/avinashn/vuejs-consumer-laravel-API
Link: