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

127
Views
Passing data from vendor API to client side for processing

I have a bog standard nodejs and express app. I then have a 3rd party API call (https://github.com/agilecrm/nodejs) that has a set function to collect the data I require. Normally, with an DB call, I am fine, where I call the data return it via res.json(data) and and its available client side in the public folder from express, but I seem to really be struggling with the format of the 3rd party function to get the data to return so I can collect it client side.

Here is an example of the api call:

var AgileCRMManager = require("./agilecrm.js");
var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
var success = function (data) {
   console.log(data);
};
var error = function (data) {
    console.log(data);
};

obj.contactAPI.getContactsByTagFilter('tester tag',success, error);

This works fine to console the data, but I need to get it client side so I can use it in the front end, and the only method I know is via routing, how would I achieve this, or is there a better method? Its the fact where the data runs via the 2nd element in the function, that I can't get in my response in the various methods I have tried.

app.get('/get_contacts_by_tag', function (req, res) {   
   obj.contactAPI.getContactsByTagFilter('Confirmed', success, error);
   var success = function (data) {
      res.json(data);
   };
});

Any help would be greatly appreciated.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You didn't define the error callback and also you assign the success callback after the api call.

app.get('/get_contacts_by_tag', function (req, res) {   
   var success = function (data) {
      res.json(data);
   };
   var error = function (data) {
      res.status(500).json(data);
   };
   obj.contactAPI.getContactsByTagFilter('Confirmed', success, error);
});
about 4 years ago · Santiago Trujillo Report
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!