when using the fetch instruction in javascript, in the following format:
fetch (destination, data_packet)
.then(response => response.json())
.then(data => {})
.catch ((error)=>{console.error ('Error: ',error)});
If an error is thrown such as:
Error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Is there away to see the raw data that was received by the call and resulted in the parsing error, rather than just the error message?
Just in case anyone is looking for something similar found the answer at Fetch API get raw value from Response
fetch(url)
.then(response => response.text())
.then((dataStr) => {
console.log (dataStr);
let data = JSON.parse(dataStr);
data...
get content of response as text and then in next phase convert text to JSON - but can output text returned first to see what might be causing the error.