Closed geowasim closed 2 years ago
I guess one line solve the problem I added : window.Buffer = Buffer; inside the file
import { Invoice } from "@axenda/zatca"; import {Buffer} from "buffer";
function App() { window.Buffer = Buffer;
const invoice = new Invoice({ sellerName: "Axenda", vatRegistrationNumber: "1234567891", invoiceTimestamp: "2021-12-04T00:00:00Z", invoiceTotal: "100.00", invoiceVatTotal: "15.00", });
Thanks but using this its not solved I got another solution import * as Buffer from '../node_modules/buffer/index'; (window as any).global = window; (window as any).process = {}; (window as any).process = window; (window as any).process.browser = true; (window as any).process.version = ''; (window as any).process.versions = { node: false }; (window as any).global.Buffer = Buffer.Buffer;
These are need to add in polyfills.ts then issue resolve
Uncaught ReferenceError: Buffer is not defined at toHex (to-hex.js:14:1) at Tag.toTlv (tag.js:19:1) at to-tlv.js:10:1 at Array.map ()
at toTlv (to-tlv.js:10:1)
at _c (ComponentToPrint.js:17:1)
at renderWithHooks (react-dom.development.js:16305:1)
at updateForwardRef (react-dom.development.js:19226:1)
at beginWork (react-dom.development.js:21636:1)
at beginWork$1 (react-dom.development.js:27426:1)
import { Invoice } from "@axenda/zatca";
function App() { console.log(Invoice); --- ok
const invoice = new Invoice({ sellerName: "Axenda", vatRegistrationNumber: "1234567891", invoiceTimestamp: "2021-12-04T00:00:00Z", invoiceTotal: "100.00", invoiceVatTotal: "15.00", });
console.log(invoice.toTlv()); --- throw error in console .....