vizceral
vizceral copied to clipboard
Problem with making updateData work with remote endpoints
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.
Isn't res.body
a string? You have to JSON.parse(res.body)
first. Or if you are using fetch, use res.json()
.
thanks, will try definitely. Will post an update as soon as possible.
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.
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)