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

223
Views
How to send current date time to Rest Api with put request in react js?

I am using axios in react js to send data in put request. it was working perfectly but when I tried to send current datetime with put request its giving me error .

Bad Request: /buyer/OrdersAPI/14/
[03/Oct/2021 14:19:44] "PUT /buyer/OrdersAPI/14/ HTTP/1.1" 400 132

I have to post current date and time to rest api date time field

My code

const api = axios.create({
    baseURL: 'http://localhost:8000/buyer/'
})
updateOrderStatus = async(id,status) => {
        let data = new FormData();
        data.append('status',status );
        data.append('orderStartTime',Date())
        await api.put(`OrdersAPI/${id}/`, data);
        this.getNewOrders();
    }

if I console.log(Date()) its giving me Sun Oct 03 2021 14:28:59 GMT+0500 (Pakistan Standard Time)

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

0

The problem is that you pass a Date object so to fix that you need to convert it to json format like this

new Date().toJSON()

this will return a result like this

console.log(new Date().toJSON())

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!