Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda