skip to Main Content

i struggle to do something that look simple with axios :

Here is my axios query :

axios.get('/consumption_reports', {
    params: {
        exists: {
            energyDeliveryPoint : false
        }
     }
})

The result is this query :

consumption_reports?exists={"energyDeliveryPoint":false}

When i would like this result :

consumption_reports?exists[energyDeliveryPoint]=false

I tried many different solution but could not found the one that works.
I look forward any answer that keep code simple.
PS : I do not want to hard code the url with my desired behavior.

2

Answers


  1. Chosen as BEST ANSWER

    I finally found myself, in that case i have no choice to do this :

    axios.get('/consumption_reports', {
        params: {
            "exists[energyDeliveryPoint]": false
        }
    })
    

  2. It works with Axios 1.x

    import axios from 'axios';
    
    const {data} = await axios.get('http://httpbin.org/get', {
      params: {
        exists: {
          energyDeliveryPoint : false
        }
      }
    });
    
    console.log(axios.VERSION, data.url); // 1.3.0 http://httpbin.org/get?exists[energyDeliveryPoint]=false
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search