In this lesson, we will learn how to work with Pinia to manage the state and values used for the form, and how to send a request to the server using the Axios library when a user submits the form and reads the response from the server.
First, we need to install the Axios library for requests to API:
npm install axios --save
Then create a new file src/bootstrap.js with the following content:...
What is the point of using a "store"? To deport the logic of the registration process or to manage the form with the pending data? Couldn't we manage the form directly in the "register" component?
Composition API allows to extract logic from components and reuse it across multiple components, which can improve the readability and maintainability of the code.
Of couse we can manage logic directly in register component without much of a side effects, but the goal was to show how to apply Composition API logic. This can be particularly useful in large applications, where it is common to have multiple components that need to share the same functionality.
In addition applying this pattern it helps to organize your code.
Thanks David ;)