A user using the chat system will report an issue, this will be sent to RestDB and as an admin when you log in to get these reports. I'm using the Ajax GET function on RestDB to call these reports back and display them in the 'display Vals' section. I have been trying different things. I keep getting the "Uncaught SyntaxError: Unexpected token o in JSON at position 1" error. I have a screenshot of this included below. Just wondering if anyone could guide me as to where I'm going wrong? Previously I didnt have the loop included and just had var string = JSON.parse(response); along with document.getElementById('displayVals').innerHTML = x; This wouldn't throw the error but the results would display as undefined.
<script>
export default{
methods:{
reportsMethod(){
var x = document.getElementById("report");
console.log(x);
var button = document.getElementById('reportBtn').addEventListener('click', () => {
/* once everything is ok, post info to report db*/
this.$f7.dialog.alert('Report: ' + x +'<br>Sucessfully gotten ');
var settings = {
"async": true,
"crossDomain": true,
"url": "https://yoururl",
"method": "GET",
"headers": {
"content-type": "application/json",
"x-apikey": "xxxxxxxxxxxxxxxxxxxxx",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
var string = JSON.parse(response);
// for(var i = 0; i < string.length; i++){
// var x = string[i];
document.getElementById('displayVals').innerHTML = string;
// }
});
});
}
}
}
</script>
