vizceral icon indicating copy to clipboard operation
vizceral copied to clipboard

Problem with making updateData work with remote endpoints

Open denismakogon opened this issue 6 years ago • 4 comments

Original issue: https://github.com/Netflix/vizceral-example/issues/42

So, the idea is pretty straightforward, i have an endpoint that ships config in application/json or application/octet-stream format, the content of the response is valid (tried to save data into a file and it worked). But when i'm trying to make an application get the config from the endpoint - UI starts hanging forever, code looks like:

  beginSampleData () {
      this.traffic = { nodes: [], connections: [] };
      request.get('https://<service-endoint>/config.json')
          .set('Accept', 'application/json')
          .end((err, res) => {
              if (res && res.status === 200) {
                  this.traffic.clientUpdateTime = Date.now();
                  this.updateData(res.body);
              }
          });
  }

I can see that the app is capable to reach out my endpoint and the request was successful, but no luck displaying the graph, unfortunately.

denismakogon avatar Apr 15 '18 08:04 denismakogon

Isn't res.body a string? You have to JSON.parse(res.body) first. Or if you are using fetch, use res.json().

jrsquared avatar Apr 18 '18 15:04 jrsquared

thanks, will try definitely. Will post an update as soon as possible.

denismakogon avatar Apr 18 '18 16:04 denismakogon

Unfortunately, nothing changed, UI still hangs attempting to render the UI. Endpoint returns a valid JSON object:

< HTTP/1.1 200 OK
< Content-Length: 2042
< Content-Type: application/json
< Date: Wed, 18 Apr 2018 17:37:23 GMT

and i applied JSON.parse function to a body, still nothing.

denismakogon avatar Apr 18 '18 17:04 denismakogon

you could try the way I did it

git clone https://github.com/eperry/node-red-contrib-viceral

Follow the install in README.md.

I used an App called "NODE-Red" which hosts the vizceral site/example

And instead of changing the example/code site. I made the data file "Dynamic" this way there is no changes to the endpoints.

plus with node-red I can build work flows to populate the data. (As provided in my example it works with Elasticsearch)

eperry avatar Jul 22 '18 18:07 eperry