I'm trying to print raw text from a web page (PWA app). I own a USB printer configured in CUPS on the same machine showing the web page - of course I'm writing Javascript code.
I built a fetch() request like:
fetch('http://'+ip+':'+port+'/printers/'+printer, {
method: 'POST',
mode: 'no-cors',
headers: {
'Content-Type': 'application/ipp'
},
body: reqBody
})
.then(response => console.log(response))
.catch(response => console.error(response))
Into the reqBody variable I stored an ipp request.
The response is (from javascript console):
Response {type: "opaque", url: "", redirected: false, status: 0, ok: false, …}
body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 0
statusText: ""
type: "opaque"
url: ""
In the Respose view I see the CUPS web page (so HTML code) .. in my understanding it should be ipp data in a HTTP packet, should it?
Where is my error? thanks
The PHP modulre for Apache was not enabled :(