Esta es mi clase Api. Inicializo la variable cliente en init:
export default class Api { constructor (options = {}) { this.init() } async init () { this.config = await this.loadConfig() this.client = this.initClient() this.client.open() } initClient() { ... } loadConfig() { ... } fetchList() { console.log(this.client, this.config) } }Ni el cliente ni la configuración son accesibles desde la función fetchList . Pero se inicializan y tienen valor cuando los registro en la consola desde la función de inicio .
editar llamo fetchList desde reaccionar useEffect
useEffect(() => { let api = new Api() api.fetchTaskList({ type: 'active' }) .then((data) => { console.log(data) }) },[])