I want to take data from JSON requests with ajax and plot data according to specific fields. When I request link:
http://127.0.0.1:8000/sensor/print/
I get a response as JSON:
{"temp0": "10", "temp1": "30", "voltage": "10", "current": "100"}
Then i create a js:
$(document).ready(function(){
    function secret(){
    $.ajax({
              type: "GET",
              url: 'http://127.0.0.1:8000/sensor/print/',
              data: {get_param: 'temp0'},
              dataType: 'json',
              success: function (data) {
                return Number(data.temp0);
              }
            });
    }
    Plotly.newPlot('simple',[{
        y: [1,2,3].map(secret),
        mode: 'lines',
        line: {color: '#80CAF6'}
    }]);
        var interval = setInterval(function() {
                  Plotly.extendTraces('simple', {
                    y: [[secret()]]
                  }, [0])
                  if(++cnt === 100) clearInterval(interval);
                }, 300);
        });
and as result, I have a moving plot without any print or my values. How can I get my values from the JSON response and plot a graph with it?
 
    