I'm wondering how do i convert a curl command to execute a bash script with associating input vars by utilising fetch?
The following works perfectly through the console.
curl -s http://localhost:3001/ident.sh | bash /dev/stdin x627306090abab3a6e1400e9345bc60c78a8bef57 2 1019489767657645
But then whenever I try to call it using fetch and even 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)
})
Which just results in:
Uncaught (in promise) SyntaxError: Unexpected token # in JSON at position 0