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

196
Vistas
How can I have javascript check different values from a checkbox group?

I have an HTML checkmark group that looks like this:

Show:
[ ] New
[ ] Regulars
[ ] Veterans

In my javascript code, I use Axios to connect to a .Net API like this:

const fetchGamerTags = async (showNew, showRegulars, showVeterans) => {

    let apiAddress = "";
    
    if (showNew) {
        apiAddress = "api/tags/GetNew/"
    } else if (showRegulars) {
        apiAddress = "api/tags/GetRegulars/"
    } else if (showVeterans) {
        apiAddress = "api/tags/GetVeterans/"
    } else {
        apiAddress = "api/tags/GetAll/"
    }
    
  const result = await axios(apiAddress, {
    params: {
      isDeleted: false
    }
  });
  

My problem is, I don't know how to handle if a user selects multiple choices...like New and Veterans. Is there a way to handle that in my javascript?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

use axios.all to get multiple requests

const fetchGamerTags = async (showNew, showRegulars, showVeterans) => {

    let getNew = axios.get("api/tags/GetNew/", {params: {isDeleted: false}});
    let getRegulars = axios.get("api/tags/GetRegulars/", {params: {isDeleted: false}});
    let getVeterans = axios.get("api/tags/GetVeterans/", {params: {isDeleted: false}});
    
    if(showNew && showRegulars && showVeterans) {
        const result = await axios.get(apiAddress, {
        params: {
          isDeleted: false
        }
      });
    } else {
       
    list = [];
    
    if (showNew) {
        list.push = getNew;
    }
    if (showRegulars) {
        list.push = getRegulars;
    } 
    if (showVeterans) {
        list.push = getVeterans;
    }

  const result = await axios.all(list, {
    params: {
      isDeleted: false
    }
  });
  }
  return result;
  }

about 4 years ago · Juan Pablo Isaza Denunciar
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