Replies: 1 comment 1 reply
-
Hi, @ylaplace: Did you find a solution? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Good afternoon,
I have an error using ngneat-transloco with angular.
i test translo module in fuse app
`import { Translation, TRANSLOCO_CONFIG, TRANSLOCO_LOADER, translocoConfig, TranslocoModule, TranslocoService } from '@ngneat/transloco';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { environment } from 'environments/environment';
import { TranslocoHttpLoader } from 'app/core/transloco/transloco.http-loader';
@NgModule({
exports : [
TranslocoModule
],
providers: [
{
// Provide the default Transloco configuration
provide : TRANSLOCO_CONFIG,
useValue: translocoConfig({
availableLangs : [
{
id : 'en',
label: 'English'
},
{
id : 'tr',
label: 'Turkish'
},
{
id : 'fr',
label: 'french'
},
{
id : 'ar',
label: 'arabe'
}
],
defaultLang : 'en',
fallbackLang : 'en',
reRenderOnLangChange: true,
prodMode : environment.production
})
},
{
// Provide the default Transloco loader
provide : TRANSLOCO_LOADER,
useClass: TranslocoHttpLoader
},
{
// Preload the default language before the app starts to prevent empty/jumping content
provide : APP_INITIALIZER,
deps : [TranslocoService],
useFactory: (translocoService: TranslocoService): any => (): Promise => {
const defaultLang = translocoService.getDefaultLang();
translocoService.setActiveLang(defaultLang);
return translocoService.load(defaultLang).toPromise();
},
multi : true
}
]
})
export class TranslocoCoreModule
{
}
`
`import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Translation, TranslocoLoader } from '@ngneat/transloco';
@Injectable({
providedIn: 'root'
})
export class TranslocoHttpLoader implements TranslocoLoader
{
/**
* Constructor
*/
constructor(
private _httpClient: HttpClient)
{
}
}
`
`import { NgModule, Optional, SkipSelf } from '@angular/core';
import { AuthModule } from 'app/core/auth/auth.module';
import { IconsModule } from 'app/core/icons/icons.module';
import { TranslocoCoreModule } from 'app/core/transloco/transloco.module';
@NgModule({
imports: [
AuthModule,
IconsModule,
TranslocoCoreModule
],
exports: [
TranslocoCoreModule
]
})
export class CoreModule
{
/**
* Constructor
*/
constructor(
@optional() @SkipSelf() parentModule?: CoreModule
)
{
// Do not allow multiple injections
if ( parentModule )
{
throw new Error('CoreModule has already been loaded. Import this module in the AppModule only.');
}
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ExtraOptions, PreloadAllModules, RouterModule } from '@angular/router';
import { MarkdownModule } from 'ngx-markdown';
import { FuseModule } from '@fuse';
import { FuseConfigModule } from '@fuse/services/config';
import { FuseMockApiModule } from '@fuse/lib/mock-api';
import { CoreModule } from 'app/core/core.module';
import { appConfig } from 'app/core/config/app.config';
import { mockApiServices } from 'app/mock-api';
import { LayoutModule } from 'app/layout/layout.module';
import { AppComponent } from 'app/app.component';
import { appRoutes } from 'app/app.routing';
const routerConfig: ExtraOptions = {
preloadingStrategy : PreloadAllModules,
scrollPositionRestoration: 'enabled'
};
@NgModule({
declarations: [
AppComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
RouterModule.forRoot(appRoutes, routerConfig),
})
export class AppModule
{
}
i have an error when run project after submit signin throw server side
ngneat-transloco.js:546 Error while trying to load "en" Error: The inspected token doesn't appear to be a JWT. Check to make sure it has three parts and see https://jwt.io for more. at Function._decodeToken (auth.utils.ts:205:19) at Function._getTokenExpirationDate (auth.utils.ts:228:35) at Function.isTokenExpired (auth.utils.ts:36:27) at AuthInterceptor.intercept (auth.interceptor.ts:48:48) at HttpInterceptorHandler.handle (http.mjs:1426:33) at HttpXsrfInterceptor.intercept (http.mjs:2024:25) at HttpInterceptorHandler.handle (http.mjs:1426:33) at FuseMockApiInterceptor.intercept (mock-api.interceptor.ts:39:25) at HttpInterceptorHandler.handle (http.mjs:1426:33) at FuseLoadingInterceptor.intercept (loading.interceptor.ts:42:21)
Beta Was this translation helpful? Give feedback.
All reactions