Reputation: 1033
When making a program that gets data from the server in json format, the program works in MS Windows (and on my Mac) but not on Chrome and Safari on IPad
(Putting one tab chrome on Ipad to the URL: chrome://inspect you get access to a very simple debug tool for getting output from errors and console.log() calls accross all tabs from chrome. )
My code:
async function fetchData(){
console.log('started') //this is the only comment
// shown in chrome://inspect pannel
const response = await fetch(checkRep, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
parameter1: 'param1',
parameter2: 'param2',
})
})
const json= await response.json();
console.log(json) //appears on chrome windows and on mac
//but it does not appear on chrome://inspect on IPad
doSomething(json);
}
function doSomething(json){
console.log(json+'<br>this comment does not appear on chrome://inspect')
}
Upvotes: 0
Views: 40
Reputation: 1033
The issue is now SOLVED. I had a javascript error in the basic code wich only appeared as error in Javascript for IPad. (Date conversion error) The rather poor error reporing in chrome://inspect (or maybe I just don't understand how to get error messages out using chrome://inspect ) made me go in the wrong direction. And the code is now working also on IPad.
For debugging I recommend these extra lines
//extra debug start
let respTxt=response.clone()
const txt=await respTxt.text()
console.log(txt); //You will get error messages from the server here
//extra debug end
const json= await response.json();
console.log(json) //Now appears on all platforms incl. IPad
regarding the issue regarding date conversion error.
The new Date(Args).getTime()-function:
let Year=document.querySelector('#year').value
let Month=document.querySelector('#month').value
let Day=document.querySelector('#day').value
let timeStamp= new Date(Year,Month,Day).getTime()
has an override where you may one string as argument, this override works in Windows and Mac, but does not work in Chrome for IOS on IPad, causing the root failure in this case
Upvotes: 0