[英]Google Cloud Endpoint no result via JavaScript Client
I am hosting an GAE Application and try to get Google Clound Endpoints to work. 我正在托管GAE应用程序并尝试使用Google Clound端点工作。 Now everything is setup and tested with curl:
现在一切都是用curl设置和测试的:
curl http://localhost:8888/_ah/api/myendpoint/v1/queryData
Returns exactly 1 item which is correct: 返回正确的1项是正确的:
{
"items" : [ {
"id" : "220",
"timestamp" : "1371475009682951",
"identifier" : "test1.0",
"value" : "523"
} ]
}
For no reason the same call through my JavaScript client returns nothing: 没有理由通过我的JavaScript客户端进行同样的调用返回任何内容:
gapi.client.myendpoint.queryData().execute( function(result) {
console.log("result: " + result);
});
The output I get is: 我得到的输出是:
result: [object Object]
What am I missing out? 我错过了什么? Thanks for your help.
谢谢你的帮助。
result
is already a JSON Object and not a string. result
已经是JSON对象而不是字符串。
With "result: " + result
you force casting the object to a string and [object Object]
is just the way this is displayed by default. 使用
"result: " + result
强制将对象强制转换为字符串, [object Object]
就是默认显示的方式。
For example console.log("result: " + {"name": "I'm an object!"})
will give you exactly the same output 例如
console.log("result: " + {"name": "I'm an object!"})
会给你完全相同的输出
Try console.log(result)
instead and you should see the real contents of the response. 尝试使用
console.log(result)
,您应该看到响应的真实内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.