Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
I have a getList method that receives parameters, but that method is used in 2 different pages. And I get an error in one of them. VUE JS .NET

good night everyone. I have the following question. I have a getList method created, which receives an articuloTipoId parameter. The issue is that this method, I had not realized that I use it on 2 screens. This is my getList method:

    /// <summary>
    /// Listado completo de objetos.
    /// </summary>
    [HttpGet("getList/{articuloTipoId}")]
    public async Task<ActionResult<List<Articulo>>> GetList(int? articuloTipoId)
    {
        string[] _include = { nameof(Articulo.CondicionIva), nameof(Articulo.Rubro), nameof(Articulo.ArticuloTipo), nameof(Articulo.UnidadMedida) };
        var result = await _articuloServices.GetListAsync(a => a.Id > 0
                                                            && (articuloTipoId == null || a.ArticuloTipoId == articuloTipoId)
                                                            , _include);
        return result;
    }

And I use it on these screens. In this function the method passes well. (I use the articuloTipoId to filter). Here everything is going well for me. Filter by the id that I have passed.

getList() {
  const articuloTipoId = this.articuloTipo != null ? this.articuloTipo : "";
  console.log(articuloTipoId)
  Swal.fire({
    title: "Espere unos momentos ...",
    showConfirmButton: false,
  });
  this.articuloServices
    .getList(articuloTipoId)
    .then((data) => {
      Swal.close();
      this.list = data;
    })
    .catch((error) => {
      Swal.close();
      this.showError(error.response.data);
    });
},

The problem arises because I had not realized that I use it on another screen. Then it starts throwing errors at me. Because what I need is to somehow use the same method in both. But in the other try to put null, empty... But I can't find a way to not throw the error.

getList() {
            Swal.fire({ title: 'Espere unos momentos ...', showConfirmButton: false });
            this.articuloServices
                .getList()
                .then((data) => {
                    Swal.close();
                    this.list = data;
                })
                .catch((error) => {
                    Swal.close();
                    this.showError(error.response.data);
                });
        },

The solution I am looking for is that the code is above, find a way so that it does not throw me that articuloTipoId is undefined, since it breaks the call to the method. Below I attach an image of the error that I get.

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda