@navios/angular-module
TypeScript icon, indicating that this package has built-in type declarations

0.3.0-alpha.2 • Public • Published

Navios Angular Module

axios replacement for Angular with axios API based on native fetch implementation.

Why?

axios is a great library, but it has some issues:

  • It's not using native fetch API, so it's slow and buggy on backend
  • It's not supporting Next.JS caching mechanism

Installation

npm install --save @navios/angular-module

or

yarn add @navios/angular-module

Integration app.config.ts

import { NaviosModule } from '@navios/angular-module'

export const appConfig: ApplicationConfig = {
  providers: [
    //...
    NaviosModule.provideNavios({
      baseURL: 'https://example.com/',
    }),
    //...
  ],
}

Usage

import { Inject, Injectable } from '@angular/core'
import type { NaviosError, NaviosService } from '@navios/angular-module'

@Injectable({
  providedIn: 'root',
})
export class SomeService {
  constructor(@Inject(NaviosService) private readonly navios: NaviosService) {}

  async load(uri, urlParams) {
    const response = await this.navios.get<MyResponse>(uri, {
      params: urlParams,
    })

    //...
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @navios/angular-module

Weekly Downloads

1

Version

0.3.0-alpha.2

License

MIT

Unpacked Size

41.9 kB

Total Files

24

Last publish

Collaborators

  • arilas