Skip to content

Problemas para descargar etiquetas #1

@lpetrora-motomel

Description

@lpetrora-motomel

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions