Disable possible caching of Node.js Orchestrator to return always latest data

I want to get the latest data via odata. So https://uipathspace.com/odata/Robots returns all the robots.

But when I change for instance my robot description:

and refresh https://uipathspace.com/odata/Robots. It shows correctly the updated text:

But I created an application using the node.js Orchestrator implementation. Here I cannot see the description changes:

Is there something hardcore cached and if so how to disable it? I am not able to find that setting.

Ok interesting is, when I restart via “node server.js” than I get the latest data. So there is some caching on the node server or on the auth script of the Orchestrator node package.

But already tried different things like:

app.set('etag', false);
app.disable('view cache');
app.disable('etag');
const nocache = require('nocache');
app.use(nocache());

But that did not change anything.

The problem is that the res.send is put outside of the callback. So it never waits for the actual finish of the REST api call.

This is the base code where it just took the static result of the first request, it never updated the results:

app.get('/robots', function (req, res) {
  ...
  var orchestrator = require('./authenticate');
  var results = {};
  var apiQuery= {};
  orchestrator.get('/odata/Robots', apiQuery, function (err, data) {
    for (row in data) {
      results[i] = 
        { 
          'id' : row.id,
          ...
        };
    }
  });  
  return res.send({results});
});

The solution is to moving the res.send({results}); into the orchestrator.get, then it properly overwrites the results as it waits correctly for the callback:

app.get('/robots', function (req, res) {
  ...
  var orchestrator = require('./authenticate');
  var results = {};
  var apiQuery= {};
  orchestrator.get('/odata/Robots', apiQuery, function (err, data) {
    for (row in data) {
      results[i] = 
        { 
          'id' : row.id,
          ...
        };
    }
    return res.send({results});
  });  
});

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.