I am trying to get astronomical data from JPL Horizons https://ssd.jpl.nasa.gov/horizons/ using javascript. I just get null data back.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
</head>
<body>
<script>
async function getText(file) {
let myObject = await fetch(file, {
method: "GET", // *GET, POST, PUT, DELETE, etc.
mode: "no-cors", // no-cors, *cors, same-origin
});
let myText = await myObject.text();
return myText;
}
jplString = "https://ssd.jpl.nasa.gov/api/horizons.api?format=text&COMMAND='499'&OBJ_DATA='YES'&MAKE_EPHEM='YES'&EPHEM_TYPE='OBSERVER'&CENTER='500@399'&START_TIME='2006-01-01'&STOP_TIME='2006-01-20'&STEP_SIZE='1%20d'&QUANTITIES='1,9,20,23,24,29'"
myText= getText(jplString);
console.log(myText);
</script>
</body>
</html>
I have tried varying the method and mode, without success.
Any suggestions? Thanks in advance.