将axios响应传递给变量时,JSON.parse或JSON.stringigy无法正常工作
axios.get('api/v0/graph/instance/'+ this.props.selectedNode )
.then(response => {
console.log('Starting of tree node message' + response.data.message);
//var message = JSON.parse(response.data.message);
var RtnJSONVal = JSON.parse(response.data.message);
console.log('value of the message variable is' + RtnJSONVal.length );
var fields = RtnJSONVal;
response.data.message是如何在下面的值
{
"guid":"FCU1",
"group_parent":"room_687",
"p":{
},
"ctime":1527225563237,
"mtime":1527225563239,
"instanceOf":"FCU",
"coordinates":{
"type":"Point",
"coordinates":[
32.76473,
35.01616
],
"crs":{
"type":"name",
"properties":{
"name":"EPSG:4326"
}
}
},
"ref-in":[
{
"src":"FCU1_Extractor",
"tgt":"FCU1",
"refType":"hasAsset"
},
{
"src":"FCU1_Diffuser",
"tgt":"FCU1",
"refType":"hasAsset"
}
],
"ref-out":[
{
"src":"FCU1",
"tgt":"room_687",
"refType":"hasLocation"
}
]
}
但是,当我尝试分配给变量时,我收到错误
消息变量的值是[object Object]"