Update plot with JSON data from POST request

Found the solution: the JSON data needs to be parsed before it can be plotted.

...
$.post('/updatePlot',
    function(response) {
    var figure = JSON.parse(response);        //Parse data before plotting
    console.log(figure)
    Plotly.newPlot("graph-0", figure.data, figure.layout);
    })
  }
...