22import {usePage } from " @inertiajs/vue3" ;
33import {onMounted } from " vue" ;
44import qz from " qz-tray" ;
5- import { http } from " formjs-vue2"
65
76const page = usePage ();
87
@@ -57,12 +56,19 @@ function startQZPrint() {
5756
5857function pollPrintJobs () {
5958 setInterval (() => {
60- http .get (route (' pos.auth.printers.jobs' ),{},{
61- onSuccess (printJobs ) {
59+ fetch (route (' pos.auth.printers.jobs' ), {
60+ cache: ' no-store' ,
61+ headers: {
62+ ' Accept' : ' application/json'
63+ }
64+ })
65+ .then ((data ) => data .json ())
66+ .then ((printJobs ) => {
6267 printJobs .data .forEach ((job ) => {
6368 console .log (" job" , job);
64- http .post (route (' pos.auth.printers.jobs.printed' , {job: job .id }), {}, {
65- onSuccess () {
69+ fetch (route (' pos.auth.printers.jobs.printed' , {job: job .id }), {
70+ method: ' POST'
71+ }).then (() => {
6672 var printerOptions = (job .type === ' badge' ) ? {
6773 colorType: ' color' ,
6874 size: job .paper .mm ,
@@ -88,17 +94,21 @@ function pollPrintJobs() {
8894 qz .print (config, data).catch ((err ) => {
8995 console .error (err);
9096 });
91- }
92- });
97+ });
9398 });
94- }
95- })
99+ })
96100 },5000 )
97101}
98102
99103function findPrinters () {
100104 qz .printers .details ().then ((printers ) => {
101- http .post (route (' pos.auth.printers.store' ), {printers: printers});
105+ fetch (route (' pos.auth.printers.store' ), {
106+ method: " POST" ,
107+ body: JSON .stringify ({printers: printers}),
108+ headers: {
109+ ' Content-Type' : ' application/json'
110+ }
111+ });
102112 }).catch ((err ) => {
103113 console .error (err);
104114 });
0 commit comments