Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!