You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently I am trying to use gun for a Lit-based project. Whenever I try to call gun.user() it gives me the error: TypeError: gun.user is not a function
import{IGunInstance}from'gun';import'gun/sea';exportasyncfunctionloadGun(){// ...constgun=Gun();awaitcheckAndCreateUser(gun,'username','password');console.log('Gun loaded');}asyncfunctioncheckAndCreateUser(gun: IGunInstance,username: string,password: string){returnnewPromise<void>((resolve,reject)=>{constuser=gun.user();// !!! THIS IS WHERE IT FAILSconsole.log('user assigned');user.auth(username,password,(ack: any)=>{//...});});}
Ok, so somehow it works now, but still trying to figure out why. If I import SEA into my bundle at the entry point, everything seems fine. But as soon as I try to import SEA from a Lit component, it breaks.
import*asGunfrom'gun';// import 'gun/sea'; // !!! INCLUDING THIS LINE BREAKS SEA GLOBALLYimport'gun/axe';
export functiongetTodoRepo(): TodoRepo|null{if(!window.gun){console.log('gun is undefined');returnnull;}else{console.log("gun is defined in TODO Repo");returnTodoRepo.getInstance();}}// ...
Hi folks,
currently I am trying to use gun for a Lit-based project. Whenever I try to call
gun.user()
it gives me the error:TypeError: gun.user is not a function
Here is the relevant parts of the project:
this is my bundle entry point:
gun auth module:
This is how I included the scripts in my HTML:
What I tried so far:
window.SEA
is defined every 100ms --> no successI have seen this issue come up before but none of the solutions worked for me, so here I am.
The text was updated successfully, but these errors were encountered: