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

326
Views
How to properly send date param to axios in React

I wanted to send date as param to service with axios but when I send it goes as

messageStartDate=2021-12-21T11%3A47%3A54.810Z&messageEndDate=2021-12-21T11%3A47%3A59.718Z

I wanted to send as Iso format but there is %-A and some other things. How can I fix it.

this is how I store the date in redux.

const params = new URLSearchParams();
if (MessageDateStartValueRedux !== null)
        params.append('messageStartDate',new Date(MessageDateStartValueRedux).toISOString());
    if (MessageDateEndValueRedux !==null)
        params.append('messageEndDate',new Date(MessageDateEndValueRedux).toISOString());
    if (ValueDateStartValueRedux !== null)
        params.append('valueStartDate',new Date(ValueDateStartValueRedux).toISOString());
    if (MessageDateEndValueRedux !== null)
        params.append('valueEndDate',new Date(MessageDateEndValueRedux).toISOString());

    dispatch(setUrlParamsReducer(params));

and this is how I use it

const getQueryString = () => `${DEFAULT_URL}?page=${currentPage}&size=${pageSize}`+status;

const param = useSelector(state => state.urlParamsReducer);

console.log(param.toString());
const loadData = () => {
    const queryString = getQueryString();
    if ((queryString !== lastQuery || param.toString() !== lastParam.toString()) && !loading) { 
        axios.get(queryString, {params: param})
            .then((response) => {
                setRows(response.data.data);
                setTotalCount(response.data.totalCount);
            }).catch(() => setLoading(false));
    }
}
useEffect(() => loadData(), [param,getQueryString()]);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

%3a is the url encoding of a ':' char. The decoded url is

messageStartDate=2021-12-21T11:47:54.810Z&messageEndDate=2021-12-21T11:47:59.718Z

as expected

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!