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

142
Views
How to transfer information between controllers with Node/Express

I have two controllers, A and B. The controller A has, among other functions, the ability to GET the information from a Module. Let's call this function getA.

I export the controller with:

module.exports = controllerA

And I try to use the information in the controller B first by importing controller A:

const a = require('controllerA')

However, when I try to get the information returned by "getA", it's either undefined or "anonymous".

How could I retrieve this information?

Further information

When I try to print by console the const a, I get the following error:

type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received type function ([AsyncFunction (anonymous...)

And when I try to do a console.log(a._id) it returns undefined

I'm not sure if this matters, but controllerA depends on the user token to retrieve the information (authorization headers, bearer token...)

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!