ushelp / EasyQRCodeJS-NodeJS

EasyQRCodeJS-NodeJS is a NodeJS server side javascript QRCode image(PNG/JPEG/SVG/Base64 data url) generator. Support setting Dot style, Logo, Background image, Colorful, Title and more. Support binary(hex) data mode.
https://easyproject.cn/easyqrcode
MIT License
103 stars 53 forks source link

Error Type : Unhandled Rejection (TypeError): Image is not a constructor ( todataURL) #7

Closed amira-98 closed 4 years ago

amira-98 commented 4 years ago

I want to save the Url of the QRCode but it don't work correctly ? It's very urgent . Can anyone help me ? `codeobj = new QRCode({ text: "link", colorLight: 'transparent', width: 150, height: 150, quietZone: 10, quietZoneColor: 'transparent',

})
  .toDataURL()
  .then((data) => {
    console.info('======QRCode PNG Base64 DataURL======')
    console.info(data)
  })`
ushelp commented 4 years ago

@amira-98 It's fine in my test. could you provide a MVP project for me to test?

amira-98 commented 4 years ago

yes . How can I provide you that ?

amira-98 commented 4 years ago

link for the MVP https://github.com/amira-98/qrcodewithlogo-MVP

ushelp commented 4 years ago

The project file is empty. May I know if the issue has been fixed?

amira-98 commented 4 years ago

No, the issue is not fixed . I have till now the same problem

Le sam. 21 nov. 2020 à 03:23, Ray notifications@github.com a écrit :

The project file is empty. May I know if the issue has been fixed?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ushelp/EasyQRCodeJS-NodeJS/issues/7#issuecomment-731492562, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK3R3IXL37OLBAMRN4VOE63SQ4QBDANCNFSM4TXOHBKA .

amira-98 commented 4 years ago

MVP.rar https://drive.google.com/file/d/1hK2bd57k4JOCSInhqjTyrbqstQ_IAqI5/view?usp=drive_web

Le lun. 23 nov. 2020 à 17:39, chebbi amira amira98chebbi@gmail.com a écrit :

No, the issue is not fixed . I have till now the same problem

Le sam. 21 nov. 2020 à 03:23, Ray notifications@github.com a écrit :

The project file is empty. May I know if the issue has been fixed?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ushelp/EasyQRCodeJS-NodeJS/issues/7#issuecomment-731492562, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK3R3IXL37OLBAMRN4VOE63SQ4QBDANCNFSM4TXOHBKA .

ushelp commented 4 years ago

I think you installed wrong dependencies. If you use React(it's client-side framework), please use EasyQRCodeJS(https://github.com/ushelp/EasyQRCodeJS), not EasyQRCodeJS-NodeJS:

EasyQRCodeJS have three version for different platform:

Project Support
EasyQRCodeJS Running with DOM on CLIENT-SIDE . Browser(IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.), Electron, NW.js, ETC.
EasyQRCodeJS-NodeJS Running without DOM on SERVER-SIDE. Save image to file(PNG/JPEG/SVG) or get data url text. NodeJS, Electron, NW.js, ETC.
EasyQRCode-React-Native A QRCode generator for React Native. Generate QRCode image or get base64 data url text.
ushelp commented 4 years ago

Please move to : https://github.com/ushelp/EasyQRCodeJS#installation https://github.com/ushelp/EasyQRCodeJS#react-support https://github.com/ushelp/EasyQRCodeJS#qrcode-api

ushelp commented 4 years ago
  1. uninstall

    npm uninstall easyqrcodejs-nodejs
  2. install

    npm install easyqrcodejs
  3. App.js

    
    import './App.css'
    import React, {
    useEffect,
    useState
    } from 'react';

// ========= import * as QRCode from 'easyqrcodejs'; // =========

function App() {

const code = React.createRef();

useEffect(() => {
    console.log('creatiing qrcode')
    var text = 'www.google.com';
    new QRCode(code.current, {
        text: text,
        colorLight: 'transparent',
        width: 150,
        height: 150,
        quietZone: 10,
        quietZoneColor: 'transparent',
        logo: './logo.svg',
        logoWidth: 50, // width. default is automatic width
        logoHeight: 50,
        logoBackgroundTransparent: true
    });
}, [code]);

return ( 
<div className = 'App' >
    <div ref = {code}> </div> 
 </div>
)

}

export default App

ushelp commented 4 years ago

Closed because it is not a technical issue.