From 79453457d1158c823df80b90f0c5a39b95bf033a Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Mon, 23 Dec 2024 15:25:28 +0700 Subject: [PATCH] updated --- src/stores/linkage.ts | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/stores/linkage.ts b/src/stores/linkage.ts index a3c701c1e..adab103c6 100644 --- a/src/stores/linkage.ts +++ b/src/stores/linkage.ts @@ -18,8 +18,8 @@ export const useLinkageStore = defineStore("linkageData", () => { /** ยิง API เพื่อดึงรายการข้อมูลเครื่องอ่านบัตร * @param {any} q ค่า this ของ quasar */ - function fetchDeviceLists(q: any) { - fetch(`${apiURL.value}/smart-card/device`, { + async function fetchDeviceLists(q: any) { + await fetch(`${apiURL.value}/smart-card/device`, { method: "GET", }) .then((response) => { @@ -41,10 +41,13 @@ export const useLinkageStore = defineStore("linkageData", () => { /** connect device ที่เลือก * @param {any} q ค่า this ของ quasar */ - function readDevice(q: any) { - fetch(`${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`, { - method: "GET", - }) + async function readDevice(q: any) { + await fetch( + `${apiURL.value}/smart-card/connect/?deviceName=${devices.value}`, + { + method: "GET", + } + ) .then((response) => { if (response.ok) { return response.json(); @@ -63,7 +66,7 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function getInfo(q: any) { - fetch(`${apiURL.value}/smart-card/info`, { + await fetch(`${apiURL.value}/smart-card/info`, { method: "GET", }) .then(function (response) { @@ -86,7 +89,7 @@ export const useLinkageStore = defineStore("linkageData", () => { * @param {any} q ค่า this ของ quasar */ async function postReadIdCard(q: any) { - fetch(`${apiURL.value}/smart-card/read/`, { + await fetch(`${apiURL.value}/smart-card/read/`, { method: "POST", body: JSON.stringify({ fields: [ @@ -122,8 +125,8 @@ export const useLinkageStore = defineStore("linkageData", () => { /** setting ami environment * @param {any} q ค่า this ของ quasar */ - function amiEnvironment(q: any) { - fetch(`${apiURL.value}/ami/environment`, { + async function amiEnvironment(q: any) { + await fetch(`${apiURL.value}/ami/environment`, { method: "POST", body: JSON.stringify({ host: "lkbmabk.bma.go.th", @@ -152,8 +155,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * connect ami * @param q ค่า this ของ quasar */ - function amiConnect(q: any) { - fetch(`${apiURL.value}/ami/connect`, { + async function amiConnect(q: any) { + await fetch(`${apiURL.value}/ami/connect`, { method: "GET", }) .then((response) => { @@ -175,8 +178,8 @@ export const useLinkageStore = defineStore("linkageData", () => { * card authentication * @param q ค่า this ของ quasar */ - function authentication(q: any) { - fetch(`${apiURL.value}/smart-card/authentication`, { + async function authentication(q: any) { + await fetch(`${apiURL.value}/smart-card/authentication`, { method: "GET", }) .then((response) => { @@ -211,7 +214,7 @@ export const useLinkageStore = defineStore("linkageData", () => { "Content-Type": "application/json", }, }; - fetch(`${apiURL.value}/smart-card/verify`, requestOptions) + await fetch(`${apiURL.value}/smart-card/verify`, requestOptions) .then((response) => { if (response.ok) { return response.json(); @@ -290,8 +293,8 @@ export const useLinkageStore = defineStore("linkageData", () => { }); } - function disconnect(q: any) { - fetch(`${apiURL.value}/smart-card/disconnect`, { + async function disconnect(q: any) { + await fetch(`${apiURL.value}/smart-card/disconnect`, { method: "GET", }) .then((response) => {