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

128
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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