Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Building a Vue SPA with Laravel Part 2
Jan 30, 2018 @ 18:13:28

The Laravel News site has posted the second part of their tutorial covering the creation of a Laravel-based single page application with Vue.js. This latest tutorial picks up from part one and covers data loading and error handling.

In this tutorial, we continue Building a Vue single-page application (SPA) with Laravel by learning how to load async data from a Laravel API endpoint inside a Vue component. We will also look at error handling when an API response returns an error and how to respond in the interface.

[...] To keep the server-side data simple, our API will use fake data. In Part 3, we will convert the API to a controller with test data coming from a database.

The tutorial starts with the definition of a "users" API route and an update to the API route configuration to map the routes to the correct controllers. Next comes the frontend functionality to load in the user data with the addition of the "users" route to the current Vue.Router instance. The UsersIndex component is then added with the template and functionality to request the data from the backend API. Some final changes are made to the route handling and error handling is added for when the data loading has issues, relaying an error message back to the user.

tagged: laravel tutorial singlepageapp vuejs series part2 api backend users

Link: https://laravel-news.com/building-vue-spa-laravel-part-2


Trending Topics: