The error is bad request 400, data is this: data {\"id\":2,\"name\":\"Tuesday\",\"from\":\"21:16:09\",\"to\":\"23:16:06\"}"
I have issues converting dateTime to time in reactjs with axios.
I have no issues on Postman, but with axios i can't convert:
Here is the pre-request script on Postman:
var moment = require("moment");
pm.environment.set('from',moment().add(14, 'hours').toISOString());
pm.environment.set('to',moment().add(30, 'hours').toISOString());
Here is the form in ReactJs:
<Form onSubmit={handleSubmit} autoComplete='off'>
<Form.Input placeholder='Day' value={workinghour.name} name='name' onChange={handleInputChange}/>
<Form.Input type='time' step='2' placeholder='From' value={workinghour.from} name='from' onChange={handleInputChange}/>
<Form.Input type='time' step='2' placeholder='To' value={workinghour.to} name='to' onChange={handleInputChange}/>
And i use this to split the datetime and to get just time:
useEffect(() => {
agent.WorkingHours.list().then(response => {
let workinghours = [];
response.forEach(workinghour => {
workinghour.from = workinghour.from.split('T')[1]
workinghour.from = workinghour.from.split('.')[0];
workinghour.to = workinghour.to.split('T')[1];
workinghour.to = workinghour.to.split('.')[0];
workinghours.push(workinghour);
})
setWorkingHours(workinghours);
})
}, [])