简体   繁体   English

Google Cloud Endpoint无法通过JavaScript客户端获得结果

[英]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.

相关问题 将文件从Javascript上传到Google Cloud Endpoint - Upload file from Javascript to Google Cloud Endpoint Google Cloud Endpoints和javascript客户端停止工作 - Google Cloud Endpoints and javascript client stopped working 通过JavaScript POST到Google Cloud Vision的问题 - Problems with POST to Google Cloud Vision via Javascript 带有Angular2的Google Cloud Endpoint - Google Cloud Endpoint with Angular2 钛合金和Google Cloud Endpoint - Alloy Titanium & Google Cloud Endpoint 加载Google Javascript客户端库和自定义端点客户端库的正确方法是什么 - What is the Proper way to load the Google Javascript Client Library and a custom Endpoint Client Library 如何在Google Cloud Endpoints Javascript客户端中设置自定义标头? - How to set a custom header in Google Cloud Endpoints Javascript Client? 使用JavaScript从客户端浏览器上传到Google云端存储 - Upload from Client Browser to Google Cloud Storage Using JavaScript Google Cloud Messaging:通过JavaScript请求发送UTF-8数据 - Google Cloud Messaging: Send UTF-8 data via JavaScript request 使用 Javascript 的 Google Cloud Speech - Google Cloud Speech with Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM