Skip to content

Commit

Permalink
fix: Fixed error on get-qr-code when client is null
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Apr 14, 2023
1 parent 8277c14 commit a744ea2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/controller/sessionController.ts
Expand Up @@ -338,7 +338,7 @@ export async function getSessionState(req: Request, res: any) {

export async function getQrCode(req: Request, res: any) {
try {
if (req.client.urlcode) {
if (req?.client?.urlcode) {
const qr = req.client.urlcode
? await QRCode.toDataURL(req.client.urlcode)
: null;
Expand All @@ -352,6 +352,12 @@ export async function getQrCode(req: Request, res: any) {
'Content-Length': img.length,
});
res.end(img);
} else if (typeof req.client === 'undefined') {
return res.status(200).json({
status: null,
message:
'Session not started. Please, use the /start-session route, for initialization your session',
});
} else {
return res.status(200).json({
status: req.client.status,
Expand Down

0 comments on commit a744ea2

Please sign in to comment.