Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Failed to retrieve data with axios get from a date (Reactjs)

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)
    })
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading