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

198
Vistas
Incorrect payload in axiom post API formik

I am trying to create post request using formik in reactjs. but it is taking value: in payload thats why 400 error is coming.

const handleSubmit = async (values: any) => {
    await axios
        .post('http://localhost:3000/api/certificates', {
            values,
        }).then(function (response) {
            console.log(response);
        }).catch((err) => {
            console.log('error in call');
            console.log(err);
        }); 
};

it is generating payload

{
  "values": {
    "sponser": "Hello",
    "startDate": "2021-11-22T13:50:59.073Z",
    "endDate": "2021-11-23T13:50:59.000Z",
    "phaseOfTrial": "1",
    "requestStatus": "DRAFT",
    "address": "Hello",
    "address2": "Hellpo",
    "zipCode": "12345",
    "city": "new",
    "protoColNo": "12312312",
    "molecules": "asdasda",
    "unAuthMolecule": "YES",
    "noOfSubjects": 5,
    "personInCharge": "llasdasdasda",
    "country": "asdasdasd",
    "comments": "asdasdasdasd",
    "attachedFile": "asdasdasd"
  }
}

in the payload it is taking values: in the beginning which my API not expecting. what mistake I am doing? how can I remove this?

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

0

I think it would work. There is shorthand assignment being done when you do like this {values} => {values: values} Thank you

await axios
    .post('http://localhost:3000/api/certificates',values)
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