Services
The services are responsible for consuming data from the servers and are very important for the business logic of the application
Last updated
Was this helpful?
The services are responsible for consuming data from the servers and are very important for the business logic of the application
Last updated
Was this helpful?
In theapp/
folder there are a series of documents that are preconfigured and ready to be extended. Among these we have some that are intended for the creation of our services.
If theservice
in question is not going to answer aCRUD
it is possible to extend only fromHttp
and have access only to the methods referring toHTTP
verbs.
A service created to solve basic operations will extend fromRest
and will have a syntax similar to the image below.
Http
The Http class is the basis for Rest and is an abstraction of an HTTP client. By default it will use theaxios
that is created insrc/settings/http.js
, which uses the value of the.env VUE_APP_REST_BASE_URL
entry asbaseURL
.
Rest
To supply the 4 pillars of the management of the entities, it already has thecreate
, read
, update
and destroy
methods, as well as thesearch
/paginate
paginate method to deal with data search and pagination.
to adapt to the different APIs there are two functions insrc/settings/rest.js
that can be adapted to extract the data from the request response and pass to the format that the project expects