Estoy tratando de encontrar una manera de crear algo como http client service
, que proporcionará una implementación repetitiva para las llamadas de back-end basadas en una breve descripción del esquema API.
Me gustaría saber si es posible registrar el Proxy es6 como servicio angular.
Necesito algo como eso:
import { Injectable } from "@angular/core"; const API = Object.freeze({ 'user': { endpoint: '/api/user/:id', methods: ['GET', 'POST'] }, 'users': { endpoint: '/api/users', methods: ['GET', 'POST'] } }); // HOW TO: register something like this @Injectable({ provideIn: 'root'}) const HttpClient = new Proxy(API, { apply(target, thisArg, ...args) { // Internal implementation } });