I am using Quagga JS scanner and trying to fetch the barcode resulted from operation with the barcode.monster API.
But i'm getting an error called "opaque" and have status 0. Any idea what is it?
Website : https://barcode.monster/api/
Quagga.onDetected(function(data) {
// //Once barcode detecterd, fetch from barcode.monster
fetch('https://barcode.monster/api/' + data.codeResult.code, {
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
}})
.then(response => console.log(response))
.catch((error) => {
console.error('Error:', error);
});
console.log("This is the scanner output: " + data.codeResult.code);
Quagga.stop();
})
If i try response.json()
I will get an error which says Unexpected end of input on the line where the json method is located.
Also, if i try with text() method, I get a blank result.
So far I was playing with the link and did not figure out. Studied some Fetch documentation, because I'm a beginner.
Response {type: "opaque", url: "", redirected: false, status: 0, ok: false, …}
body: null
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 0
statusText: ""
type: "opaque"
url: ""
The above text is the response...