Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda