Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!