如何使用特定Google产品的Google API JSON数据

时间:2012-07-16 19:29:20

标签: node.js google-api

我在解析从Google Product中的产品查询收到的数据时遇到问题。如果我运行类似于...的查询

curl --header "Authorization:GoogleLogin Auth=<AuthKey>" --header "Content-Type:application/atom+xml" https://content.googleapis.com/content/v1/8076653/items/products/generic?alt=json

我收到一份JSON(ish?)文档,类似于以下

{
  "version":"1.0",
  "encoding":"UTF-8",
  "feed":{
  ...
  }
}

但是当我运行以下

res.on('end', function() {
  console.log(res.body.feed);
  mainRes.send(res.body);
});

控制台显示未定义。

1 个答案:

答案 0 :(得分:0)

应该......

res.on('end', function() {
  console.log(JSON.parse(res.body).feed);
  mainRes.send(res.body);
});
相关问题