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

145
Views
Axios post request failed with status code 400

I am getting a status code 400 for the following request but it's working fine in postman.

function App() {
  function sendRequest(){
    let body={
        client_id: 'val1',
        client_secret: 'val2',
        code: '12345',
        grant_type: 'authorization_code',
        redirect_uri: 'exp://127.0.0.1:19000'
    };
    let config = {
      headers:{
        'Content-Type': 'application/x-www-form-urlencoded',
      }
    }
    axios.post('https://www.example.com',body,config).then((res)=>{
      console.log("The response is: "+res)
    }).catch(err=>console.log("The error is: "+err))
  }

  return (
    <div className="App">
     <button onClick={()=>sendRequest()} >Run</button>
    </div>
  );
}

This is the output on console I am getting, The error is: Error: Request failed with status code 400

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try this way:

function App() {
      function sendRequest(){
        let params =new URLSearchParams();
        params.append('client_id','val1');
        params.append('client_secret','val2');
        params.append('code','12345');
        params.append('grant_type','authorization_code');
        params.append('redirect_uri','exp://127.0.0.1:19000');
        axios.post('https://www.example.com',params).then((res)=>{
          console.log("The response is: "+res)
        }).catch(err=>console.log("The error is: "+err))
      }
    
      return (
        <div className="App">
         <button onClick={()=>sendRequest()} >Run</button>
        </div>
      );
    }
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!