GithubHelp home page GithubHelp logo

Comments (6)

fvoska avatar fvoska commented on September 27, 2024

Hi @stefan-willems-beech, can you please try using the following versions:

"@datx/core": "^2.4.8",
"@datx/jsonapi": "^2.4.8",
"@datx/jsonapi-angular": "^2.4.9",
"@datx/utils": "^2.4.8",

When using Angular, please use Angular's interceptors and not Datx's interceptors feature, as it is unnecessary next to Angular's interceptors.

Next, check out the instruction from @datx/jsonapi-angular docs for configuration, as there have been some changes in how the lib should be configured. We didn't communicate these changes in the best way, but if you were using CustomFetchService and setting baseFetch, that is no longer necessary and things should work with the new setup.

Your AppModule might look something like this after all is set up:

@NgModule({
  imports: [
    DatxModule.forRoot({
      baseUrl: 'https://my-api.com/'
    })
  ],
  providers: [
    {
      provide: APP_COLLECTION,
      useValue: new AppCollection(),
    },
    {
      provide: HTTP_INTERCEPTORS,
      multi: true,
      useClass: MyInterceptor
    }
  ]
})
export class AppModule {}

from datx.

stefan-willems-beech avatar stefan-willems-beech commented on September 27, 2024

I'v tried the new versions of the packages

and I am still having this issue.

AppModule

@NgModule({
    declarations: [
        AppComponent,
    ],
    imports: [
        BrowserModule,
        AuthenticationModule,
        AppRoutingModule,
        BrowserAnimationsModule,
        HttpClientModule,
        DatxModule,
    ],
    providers: [
        {
            provide: APP_COLLECTION,
            useValue: new AppCollection(),
        },
    ],
    bootstrap: [AppComponent]
})

export class AppModule {
}

AuthenticationModule

@NgModule({
    imports: [
        KeycloakAngularModule,
    ],
    providers: [
        {
            provide: APP_INITIALIZER,
            useFactory: initializeKeycloak,
            multi: true,
            deps: [KeycloakService],
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: KeycloakBearerInterceptor,
            multi: true
        }
    ]
})
export class AuthenticationModule {
}

The current implementation is working without the datx implementation

from datx.

stefan-willems-beech avatar stefan-willems-beech commented on September 27, 2024

I've tried it without and with adding the KeycloakBearerInterceptor to the providers.
Because the KeycloakAngularModule provides the interceptor on default.

from datx.

stefan-willems-beech avatar stefan-willems-beech commented on September 27, 2024

For future reference:

I have updated the way the module is imported via the forRoot and changed the location of the baseUrl from the collection to the module.

This fixed the issue

this is my current AppModule

@NgModule({
    declarations: [
        AppComponent,
    ],
    imports: [
        BrowserModule,
        AuthenticationModule,
        AppRoutingModule,
        BrowserAnimationsModule,
        HttpClientModule,
        DatxModule.forRoot({
            cache: CachingStrategy.NetworkOnly,
            baseUrl: environment.api_base_url,
        })
    ],
    providers: [
        {
            provide: APP_COLLECTION,
            useValue: new AppCollection(),
        },
    ],
    bootstrap: [AppComponent]
})

export class AppModule {
}

from datx.

fvoska avatar fvoska commented on September 27, 2024

.forRoot part was important because that is what makes DatX use Angular's HttpClient instead of the native fetch method (and Angular's interceptors do not work when using fetch)

from datx.

stefan-willems-beech avatar stefan-willems-beech commented on September 27, 2024

Yeah figured that out when I followed the changes inside the documentation (didn't really consider it), my implementation is going through some validation and the imports of the module has changed.

Thanks for the clarification

from datx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.