Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda