ewngs / szamlazz.js

Node.js client for Szamlazz.hu
MIT License
38 stars 34 forks source link

szamla respone returns undefined #43

Closed laszloerno closed 1 year ago

laszloerno commented 1 year ago

Hi,

i'm using your latest version and created a test application as since 2 days the invoice response is not working in my productive app. After contacting Szamlazz.hu they told me that nothing has been change on their side. The response of getInvoiceData is undefined.

import { Client } from 'szamlazz.js';

const szamlazas = async () => {
  const szamlazzClient = new Client({
    authToken: szamlazzHuToken,
    eInvoice: false, // create e-invoice. optional, default: false
    requestInvoiceDownload: false, // downloads the issued pdf invoice. optional, default: false
    downloadedInvoiceCount: 1, // optional, default: 1
    responseVersion: 1, // optional, default: 1
  });

  szamlazzClient
    .getInvoiceData({
      invoiceId: 'SCR-2023-121', // invoice number
      pdf: false, // downloads the pdf invoice. optional, default: false
    })
    .then((adat) => {
      console.log('szamla', adat);
    });
};

export default { szamlazas };

maybe i do something wrong please varify that the response is working for you, if yes then please share some hint where i'm wrong :) with my code.

thanks

ert78gb commented 1 year ago

Something should change on the szamlazz.hu side, if everything worked fine earlier.

I use the lib only generate invoice, so I don't know what is the expected output of the getInvoiceData method.

I debug your example and with this setup. It returns with undefined for me too. The problem is in the _sendRequest method returns with AxiosResponse in the line. AxoisResponse.data contains the response. So it should be parsed to get back the szamla data.

If szamlazz.hu did not change anything and you also did not upgraded the library then this code does not work for a while. I am opening a PR that fix this use case but I don't know who will confirm it fix cover every case

laszloerno commented 1 year ago

thanks for the prompt reply, yes now it works fine !

ert78gb commented 1 year ago

sry. I don't understand. Now after the szamlazz.hu outage everything works without the PR #44?

laszloerno commented 1 year ago

no after i implemented your fix it solved the issue.

ert78gb commented 1 year ago

ok, then we merge the PR and we will deploy a new version

laszloerno commented 1 year ago

thanks again :)