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

350
Vistas
How can I show enum values ​from API in select dropdown in reactjs?

I want to receive requests from 3 different APIs at the same time. I want the enum values ​​returned as a result of the request to be displayed on the select option. Then the user will have to choose from these options. The result of his choice will still be sent to a different API.

 function getSeverity() {   
    return axios.get(`http://localhost:8080/enum/..`);
  }
  function getCategory() {  
    return axios.get(`http://localhost:8080/enum/..`);
  }
  function getStatus() { 
    return axios.get(`http://localhost:8080/enum/..`);
  }
  useEffect(() => {
    Promise.all([getSeverity(), getCategory(), getStatus()])
      .then(function (results) {
        const severity = results[0];
        const category = results[1];
        const status = results[2];
      });
  }, []);

return (
    <div className="container">
      <div className="w-75 mx-auto shadow p-5">
        <h2 className="text-center mb-4">Add A New Field</h2>
        <form onSubmit={e => onSubmit(e)}>      
          <div className="form-group">
            <label>
              Severity
            </label>
            <select defaultValue={severity}>
              {_.map(severity, (value, key) => (
                <option value={key} key={key}>{value}</option> ))}
            </select>
          </div>
          <div className="form-group">
            <label>
              Status
            </label>
            <input
              type="text"
              className="form-control form-control-lg"
              placeholder="Enter status"
              name="status"
              value={status}
              onChange={e => onInputChange(e)} />
          </div>
          <div className="form-group">
            <label>
              Category
            </label>
            <input
              type="text"
              className="form-control form-control-lg"
              placeholder="Enter category"
              name="category"
              value={category}
              onChange={e => onInputChange(e)}
            />
          </div>         
        </form>
      </div>
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can loop through the object keys using Object.keys

Your loop will look like this.

{Object.keys(severity).map(key => (
                <option value={key} key={key}>{serverity[key]}</option> ))}

You'll get the keys in an array and using .map you can loop over it.

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