Can the library be used on the front end?
Opened this issue ยท 3 comments
suparpat commented
I believe the API library is written for Node.js? Can it also be used on the front end? Thank you!
suparpat commented
OK, I got it working using Browserify:
- Clone promptpay-qr
- npm install
- browserify index.js --s promptpayqr -o front.js
- Clone https://github.com/soldair/node-qrcode
- npm install
- npm run build
then in html file add
<canvas id="qrcode"></canvas>
<script src="front.js"></script>
<script src="qrcode.js"></script> (in node-qrcode's build/ folder)
<script>
var output = promptpayqr('123',{amount:12});
QRCode.toCanvas(document.getElementById('qrcode'), output, function (error) {
if (error){
console.error(error)
}else{
console.log('success!');
}
})
</script>
dtinth commented
Thanks for sharing!
dtinth commented
Yes it can be used on frontend but it needs to be compiled, e.g. using browserify/rollup/webpack. ๐