Hi, i am trying to connect my Node.js server with Backendless, however when i try to do asynchronous calls i get an error:
This is the invoking method:
function printingClient(request, response, query)
{
var listaPedidos = Backendless.Persistence.of(Pedido);
var dataQueryPedidos = {condition: "ID_ESTADO = PAGADO AND ID_SUCURSAL.ID_SUCURSAL = " + query.id};
listaPedidos.find(dataQueryPedidos, new Backendless.Async(procesarRespuestaParaImpresion,capturarErores)); //--- ERROR thrown here
function procesarRespuestaParaImpresion(res)
{
response.writeHead(200, {"Content-Type": "application/javascript"});
response.write(query.callback + '(' + JSON.stringify(res.data) + ')');
response.end();
}
}
And this is the error thrown in the server
_http_outgoing.js:333
throw new Error('"name" and "value" are required for setHeader().');
^
Error: "name" and "value" are required for setHeader().
at ClientRequest.OutgoingMessage.setHeader (_http_outgoing.js:333:11)
at new ClientRequest (_http_client.js:101:14)
at Object.exports.request (http.js:49:10)
at Object.exports.request (https.js:136:15)
at Object.e._ajax_for_nodejs (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\backendless.min.js:21:167)
at Object.A.find (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\backendless.min.js:34:178)
at printingClient(D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\server.js:767:56)
at Server.<anonymous> (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\server.js:106:4)
at Server.emit (events.js:110:17)
If i try to do a synchronous request i get this error instead:
module.js:338
throw err;
^
Error: Cannot find module 'httpsync'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.e._ajax_for_nodejs (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\backendless.min.js:21:277)
at Object.A.find (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\backendless.min.js:34:178)
at printingClient(D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\server.js:767:56)
at Server.<anonymous> (D:\Dropbox\Dropbox\Comete Alguito 3.0\Desarrollo\Server Side Code\Pure NodeJS\server.js:106:4)
at Server.emit (events.js:110:17)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:491:12)
6 Apr 14:49:14 - [nodemon] app crashed - waiting for file changes before starting...
Adding the httpsync module does nothing as it is not official and now it’s been deprecated.
Your help is kindly appreciated as in the example on the blog you do not make any actual requests. The login works fine in async (not in sync though) but not the queries themselves. I am using the last SDK
Best Regards,
Nicolas