axios给我发送数据时将圆形结构转换为json错误 [英] axios gives me converting circular structure to json error while sending the data

查看:414
本文介绍了axios给我发送数据时将圆形结构转换为json错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下所示:

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
            })
        });

现在是说Unhandled promise rejection (rejection id: 2): TypeError: Converting circular structure to JSON代表代码res.json({data:JSON.stringify(response)})

那么,此代码中是否缺少任何内容?

So, is there anything missing in this code ?

推荐答案

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
            })
        });

这篇关于axios给我发送数据时将圆形结构转换为json错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆