แก้ throw error

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2024-12-18 18:59:51 +07:00
parent 8c483a95a1
commit 537a388bcb
2 changed files with 47 additions and 40 deletions

View file

@ -164,12 +164,12 @@ class CheckAuth {
port: process.env.REDIS_PORT,
})
const getAsync = promisify(redisClient.get).bind(redisClient)
let reply = await getAsync("org_" + keycloakId)
if (reply != null) {
reply = JSON.parse(reply)
} else {
try {
if (!keycloakId) throw "Error calling API No KeycloakId"
try {
let reply = await getAsync("org_" + keycloakId)
if (reply != null) {
reply = JSON.parse(reply)
} else {
if (!keycloakId) throw new Error("No KeycloakId provided")
const x = await new CallAPI().GetData(
{
headers: { authorization: token },
@ -187,10 +187,10 @@ class CheckAuth {
}
return data
} catch (error) {
console.error("Error calling API:", error)
throw error
}
} catch (error) {
console.error("Error calling API:", error)
throw error
}
}
public async PermissionCreate(req: RequestWithUser, system: string) {