Creating an axios service wrapper (in Vue)

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • ts-nameof

    nameof in TypeScript

  • // src/services/lps/SynonymGroupApiService.ts import type { SynonymGroup } from '@/shared/models/entities/Synonym'; import type { Pageable, Sort } from '@/shared/requests/Pageable'; import type { Search } from '@/shared/requests/Search'; import type { Page } from '@/shared/responses/Page'; import { ServiceCacher } from '../ServiceCacher'; import { AbstractLpsApiService } from './LpsApiService'; export interface SynonymGroupFilter extends Search, Pageable, Sort {} class SynonymGroupApiService extends AbstractLpsApiService { public constructor(lpsPortalUrl: string) { super('/synonym-groups', lpsPortalUrl); } public findAllPaged({ search }: SynonymGroupFilter = {}): Promise> { return this.http.get('', { params: { search } }) .then(this.handleResponse.bind(this)) .catch(this.handleError.bind(this)); } public findById(id: number): Promise { return this.http.get(`/${id}`) .then(this.handleResponse.bind(this)) .catch(this.handleError.bind(this)); } public create(content: SynonymGroup): Promise { return this.http.post('', content) .then(this.handleResponse.bind(this)) .catch(this.handleError.bind(this)); } public update(id: number, content: SynonymGroup): Promise { return this.http.put(`/${id}`, content) .then(this.handleResponse.bind(this)) .catch(this.handleError.bind(this)); } public delete(id: number): Promise { return this.http.delete(`/${id}`) .then(this.handleResponse.bind(this)) .catch(this.handleError.bind(this)); } } const serviceCacher: ServiceCacher = new ServiceCacher( nameof(), // https://github.com/dsherret/ts-nameof SynonymGroupApiService ); export function synonymGroupApiService(baseUrl: string): SynonymGroupApiService { return serviceCacher.instance(baseUrl); }

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts