0

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 2

1

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

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

1 Comment

Thanks. Actually yes it work in axios 1.x and you helped me notify that my axios version was a bad one.
0

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

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

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.