5 Replies Latest reply on Jul 7, 2017 1:38 AM by vij G

    Calling the JavaScript API from node.js?

    Stuart Fieldhouse

      Hi All,


      I am trying to work out a way to access the JavaScript API from node.js.  I know, I know - this is a client-side API which I'm trying to access server-side . However, my goal is to create a node.js module which calls the getData() function and returns the retrieved data as JSON.  This module would be called by an Alteryx tool giving Alteryx the ability to use Tableau as a data source.  Wouldn't that be cool?


      So far I've been able to create a virtual DOM inside a virtual window using the jsdom library.  I can read the API JavaScript file from our Tableau server and inject it into the virtual DOM and even get so far as to successfully instantiate a viz object using viz = new window.tableau.Viz(containerDiv, url, options);  Unfortunately, that's where I'm stuck.  The onFirstInteractive callback on my viz object is never called and attempts to instantiate a workbook fail with a 'cannot call getWorkbook() on null' error.  I'm thinking that Tableau is waiting to be told that the view has rendered which, of course, is never going to happen.


      I'm able to access the JavaScript API fully in the 'proper' way from an HTML page in a browser, so I'm thinking it's not a configuration issue.


      Does anyone know if there is a way to 'trick' Tableau into thinking that the view has rendered?  Or a way to activate the getWorkbook/sheet functionality without first physically rendering the view?  Or any other ideas on how this problem might be aproached?