javascriptreactjsreact-nativeaxiosapisauce

How to add query, filter params in axios request


http://localhost:9000/api/res.users?sudo=1&filter=[["id","=",11]]&query={id,name,image_128,phone}

how to compose above url with axios and send it to server.

i tried params but i think i'm missing something because i'm getting

     Promise {
  "_U": 0,
  "_V": 0,
  "_W": null,
  "_X": null,
}

my code looks like thisthis was when i tried using apisauce

now using axios i tried this way

const res = axios.get('http://localhost:9000/api/res.users', {
        params:{
            sudo: '1',
            filter: '[["id", "=", 11]]',
            query: "{phone,name}"
        }
    });
    console.log("res", res);

Solution

  • Try this it will work

    axios.get('http://localhost:9000/api/res.users', {
        params:{
            sudo: '1',
            filter: '[["id", "=", 11]]',
            query: "{phone,name}"
        }
    }).then(res=>{
       console.log("res", res);
    });