I'm facing an issue with the JS function JSON.parse().
I'm working with the flask framework and my goal is to send a JSON response from web to my html template.
@app.route('/index', methods=['GET','POST'])
def index():
response_API = requests.get('http://127.0.0.1:5001/api/lotnumbers')
dataJson = response_API.json()
if request.method == "POST":
print(request.form.getlist('checkbox-case'))
return render_template('generate.html', excel=dataJson)
And I try to retrieve my data like this :
<script>
var table = JSON.parse('{{excel | tojson | safe}}');
console.log(table);
</script>
But I have always this error : Uncaught SyntaxError: Unexpected token in JSON at position 18 at JSON.parse () at (index):95:22
What's the best way to retrieve my data from a Web Response ?