0

I need to retrieve data based on a date. I tested my route with Postman and everything works fine. However, when I do my axios query with a date, it returns an empty array. I understood that it would be a date format problem with axios, but I couldn't solve it. Could you help me please?

Here is my code in the front:

const getDailyWorking =()=>{
    let datas={
        activity_creationTimestamp: ('2022-06-28'),
        user_id:1
    }

    console.log(datas)
    return axios.get(config.api_url+'/dailyWork', datas).then((response)=>{
        console.log(response.data)
    }).catch((err)=>{
        console.log(err)
    })
}
2
  • 1
    you are making get request instead of post. (2nd argument of axios.get method takes axios config not data) Commented Jul 14, 2022 at 11:12
  • You are returning and ignoring console.log(response.data) Commented Jul 14, 2022 at 11:12

2 Answers 2

2

You're using the wrong type of request. A GET request can't include a body in the request, while a POST request can include a body in the request. Maybe you should check the documentation again and get the parameters sorted.

Sign up to request clarification or add additional context in comments.

Comments

0

You can specify the GET parameters like this axios.get('/path', { params: datas } which is equivalent to axios.get('/path?activity_creationTimestamp=2022-06-28&user_id=1') . Otherwise, provide more information about the server side route.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.