I'm curious about converting a curl command into a bash script with input variables using fetch.
It works perfectly in the console:
curl -s http://localhost:3001/ident.sh | bash /dev/stdin x627306090abab3a6e1400e9345bc60c78a8bef57 2 1019489767657645
However, when I try to call it using fetch without the script arguments:
fetch("http://localhost:3001/ident.sh")
.then((resp) => resp.json())
.then((data) => {
console.log(data)
})
OR
fetch("http://localhost:3001/ident.sh", {
method: 'GET',
headers : {
'Content-Type': 'application/json',
'Accept': 'application/json' }
})
.then((resp) => resp.json()) // Transform the data into json
.then((data) => {
console.log(data)
})
This just results in:
Uncaught (in promise) SyntaxError: Unexpected token # in JSON at position 0