I am getting this error: Property assignment expected. Declaration or statement expected

building chatbot with python flask and integration with html css js web

here is the script in html file

<script>
    $SCRIPT_ROOT = {{request.script_root|tojson }};
</script>

This is from the .js file

fetch($SCRIPT_ROOT + '/predict', {
    method: 'POST',
    body: JSON.stringify({ message: text1 }),
    mode: 'cors',
    headers: {
   'Content-Type': 'application/json'
   },
})
.then(r => r.json())
.then(r => {
let msg2 = { name: "Sam", message: r.answer };
this.messages.push(msg2);
this.updateChatText(chatbox)
textField.value = ''

I searched but I dont know much about frontend please help!