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

506
Vistas
How to submit request with formik and axios

I want to post some data with Axios and I'm using formik but as formik doesn't need an external state for tracking the input fields I don't know what to pass in the payload of Axios post request


const Form = () => {

  const submitHandler = (e) => {
    e.preventDefault();
    axios
      .post("http://127.0.0.1:8000/todo/todos/", {
       // i dont know what to put here, before i use formik it was like this 
      //state,})
  };
  return (
    <Formik
      initialValues={{
        title: "",
        description: "",
      }}
      validationSchema={validate}
    >
      {(formik) => (
        console.log(formik.values),
        (
          <StyledForm onSubmit={submitHandler}>
            <div>
              <div>
                <Input
                  name="title"
                  type="text"
                />
              </div>
              <div>
                <Textarea
                  type={"text"}
                  name="description"
                  as="textarea"
                />
              </div>
            </div>
          </StyledForm>
        )
      )}
    </Formik>
  );
};

export default Form;
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Since Formik handles your values, you should use it as well for submitting your form.

The onSubmit function you pass into Formik has all your needed values.

  const submitHandler = (values) => {
    axios.post("http://127.0.0.1:8000/todo/todos/", values);
    // further handling
  };

  return (
    <Formik
      initialValues={{
        title: "",
        description: "",
      }}
      validationSchema={validate}
      onSubmit={(values) => submitHandler(values)}
    >
  ...
about 4 years ago · Santiago Gelvez 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