Error: Impossible to convert undefined to Principal.
Situation: I want to pull logged in user principal ID in the backed. I’m trying to call a backend shared query function after a user is logged in and get this error, if I try to use the backend actor created after login with a new agent.
If i use a normal actor, without a logged in user principal, the call goes fine but I get the anonyms user principal in the backed, which is expected
I’m aware that I’m facing an issue which is already discussed in this forum but the suggestions provided are not helping me or perhaps I’m missing something.
I have verified the backend canister ID is matching between process.env.CANISTER_ID_ICP_APP_NEW_BACKEND in the chrome and the canister ID itself.
I have also updated by DFX and created a brand new app with it and copied the app code to the new app from old one to the new one without touching anything else.
I guess you are creating actor in a wrong way!
If you are using the default declarations files that generated using dfx, you should initialize actor like this createActor(canisterId, options = {})