wppconnect-team / wppconnect-server

Wppconnect Server is a ready-to-use API, just download, install, and start using, simple as that.
https://wppconnect.io/swagger/wppconnect-server/
Apache License 2.0
613 stars 348 forks source link

{ "status": "error", "message": "Error retrieving QRCode" } #667

Closed bwanakweli4ever closed 1 year ago

bwanakweli4ever commented 2 years ago

error: 2022-04-15T13:24:29.303Z Cannot read property 'replace' of null - TypeError: Cannot read property 'replace' of null at getQrCode (/home/alex/wppconnect-server/src/controller/sessionController.js:286:47) at Layer.handle [as handle_request] (/home/alex/wppconnect-server/node_modules/express/li

when i request http://localhost:21465/api/NERDWHATS_AMERICA/qrcode-session the above error persists , would you guide me a bit on how i fix that please ?

prashantnirgun commented 2 years ago

I had the same problem

export async function getQrCode(req, res) {
  try {
    console.log('inside getQrCode==>', req.client);
    const img = Buffer.from(req.client.qrcode.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''), 'base64');

    res.writeHead(200, {
      'Content-Type': 'image/png',
      'Content-Length': img.length,
    });
    res.end(img);
  } catch (ex) {
    req.logger.error(ex);
    return res.status(500).json({ status: 'error', message: 'Error retrieving QRCode' });
  }
}

output

{
  status: 'CLOSED',
  session: 'NERDWHATS_AMERICA',
  config: { webhook: 'https://localhost:3000/', waitQrCode: true },
  qrcode: null,
  urlcode: '2@wswzd+N7mKt23xwAaYV0iVRyG+fhZLcxHkTkND2FximfavyScq6zWkorTeko0fvfMUv+f3Ahtnup4Q==,mUK23ND3yvl6X9XT1OaDke0Fc3uqLM5Wlu+zJBHOIFk=,yVnw9pxQbJicZSsqm3llImX1IxFMBS1AtWO3awKCyAs=,ulkCQY4RhvE6xwecIXiEc+LRDYiWVzHY5ZHoLs18v00='
}
icleitoncosta commented 1 year ago

What is the version of WAJS and WppConnect?

prashantnirgun commented 1 year ago

this issue is resolved please close this thread.