如何在 body n js 中使用 axios
how to use axios with this body n js
我在使用 axios 时遇到问题 post
我的 post body 是:
{
"action": "createRoom",
"params": {
"name": "cloud-services",
"title":"test",
"max_users": 50,
"guest_login": true
}
}
我是这样使用 axios 的:
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
}
我的实例是:
module.exports = () => {
const instance = axios.create({})
return instance
}
我收到以下错误:
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)
你试过改变吗
const result = await instance().post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } })
至
const result = await instance.post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } })
。
我认为您不需要 运行 直接实例化
我找到了正确的请求。谢谢大家
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
}
我在使用 axios 时遇到问题 post 我的 post body 是:
{
"action": "createRoom",
"params": {
"name": "cloud-services",
"title":"test",
"max_users": 50,
"guest_login": true
}
}
我是这样使用 axios 的:
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
}
我的实例是:
module.exports = () => {
const instance = axios.create({})
return instance
}
我收到以下错误:
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)
你试过改变吗
const result = await instance().post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } })
至
const result = await instance.post(Constants.URL_SKYROOM, { action, params: { name, title, max_users, guest_login } })
。
我认为您不需要 运行 直接实例化
我找到了正确的请求。谢谢大家
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
}