Services

The services are responsible for consuming data from the servers and are very important for the business logic of the application

Services Structure

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 theservicein question is not going to answer aCRUDit is possible to extend only fromHttpand have access only to the methods referring toHTTPverbs.

Example of service that uses only the Http class

A service created to solve basic operations will extend fromRestand will have a syntax similar to the image below.

Simple Rest Service

Http

The Http class is the basis for Rest and is an abstraction of an HTTP client. By default it will use theaxiosthat 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.jsthat can be adapted to extract the data from the request response and pass to the format that the project expects

Last updated

Was this helpful?