axios gives me converting circular structure to json error while sending the data
Full error message
My code is as shown below:
axios.post('https://api.sandbox.xyz.com/v1/order/new', JSON.stringify({
"request": "/v1/order/new",
"nonce": 123462,
"client_order_id": "20150102-4738721",
"symbol": "btcusd",
"amount": "1.01",
"price": "11.13",
"side": "buy",
"type": "exchange limit"
}), config)
.then(function(response) {
console.log(response);
res.json({
data: JSON.stringify(response)
})
})
.catch(function(error) {
console.log(error);
res.send({
status: '500',
message: error
})
});
Now it is saying that Unhandled promise rejection (rejection id: 2): TypeError: Converting circular structure to JSON for the code res.json({data:JSON.stringify(response)})
So, is there anything missing in this code ?Solutionsource: stackoverflow \u2197
axios.post('https://api.sandbox.xyz.com/v1/order/new', JSON.stringify({ "request": "/v1/order/new", "nonce": 123462, "client_order_id": "20150102-4738721", "symbol": "btcusd", "amount": "1.01", "price": "11.13", "side": "buy", "type": "exchange limit" }), config) .then(function(response) { res.send(response.data) }) .catch(function(error) { res.send({ status: '500', message: error }) });
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/86e6f811ae5110dafdf64ef5abdcb61eef2c7690f090d3e908f79b5f7742ba92hash \u00b7 86e6f811ae5110dafdf64ef5abdcb61eef2c7690f090d3e908f79b5f7742ba92