Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
Can't retrieve data from object to another object Javascript

I am trying to retrieve the data from a process. A module does it automatically. However, I am trying to export the data, so I tried adding it to another object and then exporting the object, but it sends an empty object.

(Here's what I am trying to retrieve if you need more context: https://hextechdocs.dev/getting-started-with-the-lcu-api )

Here's the code :

import LCUConnector from 'lcu-connector'
const connector = new LCUConnector();

const dataRetrieved = {username: ''}

connector.on('connect', (data) => {

   console.log(data) //Shows the data

   dataRetrieved.username = data.username; //Gives the username to dataRetrieved

   console.log(dataRetrieved) //Can see the username in DataRetrieved

   connector.stop() //Closes the connector

});

connector.start() //Calls the .on event

console.log(dataRetrieved) //dataRetrieved is empty + get asked before the event handler


export default dataRetrieved; //When I import in another module, it is empty

Here's the code for the event listener and the LCUConnector:

declare class LCUConnector {
        constructor(path?: string);

        static getLCUPathFromProcess(): Promise<string | void>;

        static isValidLCUPath(dirPath: string): boolean;

        start(): void;

        stop(): void;

        on(event: 'connect', listener: (data: {
            address: string,
            port: number,
            username: string,
            password: string,
            protocol: string
        }) => string): this;

        on(event: 'disconnect', listener: () => void): this;
}

export = LCUConnector;

I am missing something important, but I don't know why it doesn't store the data into my dataRetrieved object.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda