我正在使用aws从服务器上的Amazon附属API中检索数据。
var aws = require("../lib/aws");
prodAdv = aws.createProdAdvClient(yourAccessKeyId, yourSecretAccessKey, yourAssociateTag);
prodAdv.call("ItemSearch", {SearchIndex: "Books", Keywords: "Javascript"}, function(err, result) {
console.log(JSON.stringify(result));
})这个console.logs是一个包含多个对象的大型JSON文档,我现在需要在客户端调用这些具有角的对象的能力。我一直在使用app.get和$http.get与mongojs一起检索本地MongoDB数据库数据,我可以使用类似的方法吗?我试着把它贴到MongoDB数据库上,却没有任何运气。
谢谢
发布于 2016-04-20 12:19:26
app.get('/amazon', function (req, res){
prodAdv = aws.createProdAdvClient(yourAccessKeyId, yourSecretAccessKey, yourAssociateTag);
prodAdv.call("ItemSearch", {SearchIndex: "Books", Keywords: "Javascript"}, function(err, result) {
res.send(result);
});
});然后,在客户端您可以这样做:
$http.get("http://domain:port/amazon")
.then(function(response) {
//do whatever you want
});发布于 2016-04-20 12:34:13
实际上,您有两种方法来显示从node.js服务器发送的数据:
$.get('/games',function(res){ // res holds the data });<%= data %>查找关于EJS:http://www.embeddedjs.com/的更多信息https://stackoverflow.com/questions/36743082
复制相似问题