Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Error: parsing json file angular 5 #37

Open
andrei-ga opened this issue Dec 31, 2017 · 8 comments
Open

Error: parsing json file angular 5 #37

andrei-ga opened this issue Dec 31, 2017 · 8 comments

Comments

@andrei-ga
Copy link

I just updated to Angular 5. I am using asp-prerendering from .Net Core 2 feature.
I import the plugin using

        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: (createTranslateLoader),
                deps: [HttpClient, [ORIGIN_URL]]
            }
        }),

and

export function createTranslateLoader(http: HttpClient, baseHref: string) {
    // Temporary Azure hack
    if (baseHref === null && typeof window !== 'undefined') {
        baseHref = window.location.origin;
    }
    // i18n files are in `wwwroot/assets/`
    return new TranslateHttpLoader(http, `${baseHref}/assets/i18n/`, '.json');
}

I am receiving the following error: NodeInvocationException: Http failure during parsing for http://localhost:50475/assets/i18n/en.json

If I disable pre-rendering or I don't import ngx-translate plugin, everything works.

@dobrinsky
Copy link

I have the same issue

@Jacooscript
Copy link

I've faced the same bug.
image

@switch120
Copy link

Check for a trailing , or attributes not wrapped in quotes... the http.get method is pretty picky about proper JSON syntax. I had the same issue until I (finally) found the one lone trailing comma that was causing this non-descript error. HTH!

@Rabeata
Copy link

Rabeata commented Mar 12, 2018

I have the same issue
but I have Angular 4.3

@switch120
Copy link

Try using a tool to validate your JSON - that was my issue, super picky formatting; no trailing commas, wrap all attribute names in quotes, etc. Try this: https://jsonlint.com/

@andrei-ga
Copy link
Author

andrei-ga commented Mar 20, 2018

It is valid. I checked with several tools, including the one you provided.

@abeel50
Copy link

abeel50 commented Oct 2, 2020

i have same issue

@abeel50
Copy link

abeel50 commented Oct 2, 2020

Check for a trailing , or attributes not wrapped in quotes... the http.get method is pretty picky about proper JSON syntax. I had the same issue until I (finally) found the one lone trailing comma that was causing this non-descript error. HTH!

I have checked already, but there's not a typing error.
will some one guide me?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants