New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ngx-apiwrapper

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-apiwrapper

A wrapper for Angular's HttpClient for easy consumption of api endpoints

latest
Source
npmnpm
Version
1.0.10
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Ngx-Apiwrapper

This project has been put together with the aim of minimising the complexity of building repetitive HttpClient methods.

Dependencies

  • Angular v19+

Installation

npm install ngx-apiwrapper

Configuration

Add the provider to you app.config.ts (assuming you are running in standalone mode)

import { provideNgxApiWrapper } from 'ngx-apiwrapper'

export const appConfig: ApplicationConfig = {
  providers: [
    provideNgxApiWrapper({
      availableApis: {
        yourApi: 'yourfirstapi.com',
        aws: 'yourAWSApi',
        azure: 'yourAzureApi'
      },
      defaultApi: 'yourApi'
    })
  ]
}

Define your service, inject the wrapper, and call the wrapper

@Injectable({ providedIn: 'root' })
export class APIService {
    private readonly _wrapperService: ApiWrapperService = inject(ApiWrapperService);

    yourMethod() {
        return this._wrapperService.get('your-endpoint');
    }
}

Usage

The wrapper is designed to wrap up common functionality, and can be used alongside a traditional guard for authorization.

By defining the api base url in the provider, you only need to pass in the specific endpoint when you make the call to the wrapper service.

Each method accepts a path input, where you define the endpoint and an options object allowing you to define additional properties like headers or parameters.

The POST and PUT methods both accept a body input as well.

Options

The API Options allow you to pass a number of additional options.

Alongside this, any required headers defined in the config will be applied by default.

export interface APIOptions {
    apiName?: string;
    headers?: HttpHeaders | { [header: string]: string | string[] };
    params?:
        | HttpParams
        | {
            [param: string]:
            | string
            | number
            | boolean
            | ReadonlyArray<string | number | boolean>;
        };
    overridePath?: boolean;
    version?: number;
    logToConsole?: boolean;
    ignoreErrors?: boolean;
    withCredentials?: boolean;
    reportProgress?: boolean;
    observe?: 'body' | 'events' | 'response';
    errorOverride?: (err: HttpErrorResponse) => Observable<never>;
    responseType?: 'arraybuffer' | 'blob' | 'text' | 'json';
}

FAQs

Package last updated on 08 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts