'how to use axios with this body n js

I have trouble post with axios my post body is :

{
    "action": "createRoom",
    "params": {
        "name": "cloud-services",
        "title":"test",
        "max_users": 50,
        "guest_login": true
    }
}

And I use axios it like this :

  async createClassInSkyRoom({ action = "createRoom", name, title, max_users, guest_login }) {
    const result = await instance().post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } })
    return result
  }

and my instance is :

module.exports = () => {
  const instance = axios.create({})
  return instance
}

And I get the following error :‌

 err: TypeError: Converting circular structure to JSON
      --> starting at object with constructor 'ClientRequest'
      |     property 'socket' -> object with constructor 'TLSSocket'
      --- property '_httpMessage' closes the circle
      at JSON.stringify (<anonymous>)
      at stringify (/home/firefly/Desktop/project/taha-m/node_modules/express/lib/response.js:1128:12)
      at ServerResponse.json (/home/firefly/Desktop/project/taha-m/node_modules/express/lib/response.js:260:14)
      at ResponseHandler.send (/home/firefly/Desktop/project/taha-m/app/Handler/ResponseHandler.js:9:26)
      at ClassController.goToClassOnSkyRoom (/home/firefly/Desktop/project/taha-m/app/Class/class.controller.js:62:28)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)


Solution 1:[1]

I found the right request. Thank you all

  async createClassInSkyRoom({ action = "createRoom", name, title, max_users, guest_login }) {
    const result = await instance().post(Constants.URL_SKYROOM, data:{ action, params: { name, title, max_users, guest_login }})
    return result
  }

Solution 2:[2]

Have you tride to change const result = await instance().post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } }) to const result = await instance.post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } }). I think you don't need to run instace directly

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Taha roma
Solution 2 Rayan Wilbert