Skip to content

Interceptor for nativescript-background-http requests #195

Open
@progressify

Description

@progressify

Hi,
In my project, I have integrated JWT authentication with an interceptor for all HTTP request.
Exists a method for intercept the requests of nativescript-background-http?

Which platform(s) does your issue occur on?

  • Android Pie
  • Device: Google Pixel 2 XL

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
    5.0.1
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
    "tns-core-modules": "^5.0.2",
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
    "tns-ios": {
    "version": "4.2.0"
    },
    "tns-android": {
    "version": "5.0.0"
    }
  • Plugin(s): (look for the version numbers in the package.json file of your
    project and paste your dependencies and devDependencies here:
    "nativescript-background-http": "^3.3.1",

This is the code I have used to intercept all the http requests:

app.module.ts

import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';

...
...

@NgModule({
    bootstrap: [
        ...
    ],
    imports: [
        ...
    ],
    declarations: [
       ...
    ],
    providers: [
        ...
        {
            provide : HTTP_INTERCEPTORS,
            useClass: RequestInterceptorService,
            multi: true
        }
    ],
    schemas: [
        ...
    ]
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions