Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot stringify arbitrary non-POJOs PublicClientApplication #3

Open
jenmcg opened this issue Nov 28, 2023 · 2 comments
Open

Cannot stringify arbitrary non-POJOs PublicClientApplication #3

jenmcg opened this issue Nov 28, 2023 · 2 comments

Comments

@jenmcg
Copy link

jenmcg commented Nov 28, 2023

I am getting this error: Cannot stringify arbitrary non-POJOs PublicClientApplication

It's not liking the useState composable being used with something that returns functions and isn't serializable.

Stated in the docs:
Because the data inside useState will be serialized to JSON, it is important that it does not contain anything that cannot be serialized, such as classes, functions or symbols.

How do I get around this?

@Molokhai
Copy link

Molokhai commented Jan 9, 2024

I fixed it by creating a singleton class of IPublicClientApplication.

In useMSAuth.ts change the line of code with the useState to:
let msalInstance = PublicClientApplicationSingleton.create(msalConfig);

Create a singleton class of IPublicClientApplication like so:
`export class PublicClientApplicationSingleton {
private static _instance: IPublicClientApplication;

public static create(configuration: Configuration) {
    if(PublicClientApplicationSingleton._instance == null) {
        PublicClientApplicationSingleton._instance = new PublicClientApplication(configuration);            
    }
    return PublicClientApplicationSingleton._instance;
}

}`

@yijiyap
Copy link

yijiyap commented Jun 13, 2024

the singleton class didn't work for me.
You can include ssr: false in your nuxt.config.ts to remove the POJO error.

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

No branches or pull requests

3 participants