Counters not working in NodeJS

I am using the Api to get and increment a counter by using nodeJs




    console.log("Counter:");
    console.log(Backendless.Counters.incrementAndGet("Pago"));


The code works on normal HTML and jS (prints the number), but in node JS it returns False.

Nicolas,

Would you be able to inspect if a REST request goes out to our servers when you make the call?

Regards,
Mark

Sadly the debuggin tools do not allow me to make such an inspection :/. Nevertheless i can check what is being send if you give me a line to debug

Hi Nicolas,

If you search for “incrementAndGet” in the following script, there are 3 instances (two of them are on the same line). Set the breakpoint on both lines:
http://api.backendless.com/sdk/js/latest/backendless.js

Many thanks!

Mark

Hi Mark,

NodeJs debugger is not allowing me to debug prototypes… :frowning:

Hi Nicolas,

The problem is you need to use the asynchronous API. This applies to any API call you make from the Node.js environment. Could you please try again and let me know if it works?

Regards,
Mark

Sadly the asynchronous methods for counters are not working either, the callback function is never called.
Funny enough if i try to use the current BE api (not the one you kindly made for me), i get the ‘cannot find module httpsync’ error

This is the code i am using:

Backendless.Counters.getAndIncrement( 'Pago', callbackFunction );