Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problemas para descargar etiquetas #1

Open
lpetrora-motomel opened this issue Aug 25, 2022 · 0 comments
Open

Problemas para descargar etiquetas #1

lpetrora-motomel opened this issue Aug 25, 2022 · 0 comments

Comments

@lpetrora-motomel
Copy link

lpetrora-motomel commented Aug 25, 2022

Hola, estoy utilizando tu librería para acceder a la API de Andreani y encontré un problema al descargar el PDF de las etiquetas. Aparentemente axios rompe el contenido cuando se trata de un archivo binario. Para solucionarlo hay que agregar este atributo a las opciones:
responseType: 'arraybuffer'

Un fix sería modificar getReq para recibir un parámetro opcional que indique si la respuesta a recibir es un binario:

private async getReq(url: string, binary: string = false) {
  const binaryConfigAuth = () => {
    let result = this.configAuth;
    const cfg = {...result, responseType: 'arraybuffer'};
    return cfg;
  }
        
  const auth = binary ? binaryConfigAuth() : this.configAuth;

  return await axios.get(url, auth).then((x) => x.data);
 }

Y modificar el método que busca las etiquetas para que pase el parámetro:

private async $obtenerEtiqueta(remito: string) {
  return await this.getReq(this.OBT_ETQ_URL(remito), true);
}

Saludos,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant