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

177
Visualizações
I'm trying to call a Javascriptcript method in a class from another class and I get error

I'm trying to call a Javascriptcript method in a class from another class and I get an error

error
{ error: 'slackService.getAccessData is not a function' }

In the slackController.js below I called the method from slackServices.js saying slackService.getAccessData(code)

Find my slackcontroller.js below

import slackService from "../services/SlackService.js"

class SlackController {
  async handleCallback(req, res) {
    try {
      const code = req.query.code;
      console.log(code);
      if (code) {
        const { email, userData } = await slackService.getAccessData(code);

    const { slack_user_id } = userData;
  res.redirect("/")
   }  else {
    res.redirect("/");
  }
} catch (e) {
  console.log("error")
  console.log({error: e.message});
  res.json({ error: e.message });
  
}

} }

export default new SlackController();

find my slackService.js below

import Client from './WebClient.js';
import config from '../config/slack.js';
import { createReadStream } from 'fs';

class SlackService {
  async getAccessData(code) {
    const data = await this.getAccessToken(code);
    const user = await this.getUserInfo({ 
      token: data.access_token, user_id: data.authed_user.id 
    });
    
    console.log(data, user);
    return this.format(data, user);
    
  }

  async getUserInfo({ token, user_id }) {
    const wc = new Client(token);
    const { user } = await wc.users.info({ user: user_id });
    return user;
  }

  async getAccessToken (code) {
    const wc = new Client();
    // return await wc.accessToken(config(code));
    return await wc.accessToken(code);
  }
  }
}
export default SlackService;
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