简体   繁体   English

如何捕获通过HTTP GET的api调用返回的Array对象?

[英]How can I capture the Array object returned by an api call through HTTP GET?

The API call API调用
https://myhost.net/api/get_global_search_result/methods/test returns an Array object. https://myhost.net/api/get_global_search_result/methods/test返回一个Array对象。 I am trying to hold it in an Array object in order to read the attributes and values in it. 我试图将其保存在Array对象中,以便读取其中的属性和值。

var queryResult = [];  
queryResult = browser.get('https://myhost.net/api/get_global_search_result/methods/test/');
console.log('result length: ' + queryResult.length);

This is what I see on my console: 这是我在控制台上看到的:

result length: undefined

If I load the above specified URL directly in a browser instance, it shows the Array with its contents. 如果我直接在浏览器实例中加载上述指定的URL,它将显示Array及其内容。

What is the better way of capturing the array object returned by this call? 捕获此调用返回的数组对象的更好方法是什么?

What about using JQuery ajax request. 如何使用JQuery ajax请求。 it would be some thing like : 就像这样:

 $(document).ready(function() { $("#testbutton").click(function() { $.ajax({ url: 'http://localhost:9200/xyz/xyz/xfSJlRT7RtWwdQDPwkIMWg', dataType: 'json', success: function(data) { alert(JSON.stringify(data)); }, error: function() { alert('error'); } }); }); }); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何获取 get api 调用的数据,格式为 reactjs 中 object 数组中的 object 嵌套数组? - How can i fetch the data of an get api call which is in the format as nested array of object in array of object in reactjs? AngularJS-如何捕获从GET服务方法返回的JSON,而不管返回的HTTP状态如何 - AngularJS - How do I capture JSON returned from a GET service method regardless of http status returned 我如何遍历对象数组,为每个 object 调用 API,然后将响应设置为每个 object 中的值 - How can I iterate through an array of objects, make an API call for each object, then set the response as a value in each object 如何访问从 API 调用返回的 object 内部的值 - How I can access to values inside of this object returned from an API call 循环遍历JSON API调用返回的数组 - Looping Through an Array of Arrays returned by JSON API Call 就我而言,如何替换 API 返回的对象值? - in my case how I can replace an API returned object value? 如何使用 HTTP Get 请求仅获取数组中 object 中的特定属性? - How can I use an HTTP Get request to only get a specific attribute within an object in an Array? 如何获取从 api 返回的所有值? Javascript - How can I get all values returned from api? Javascript 我如何使用脚本获取Plaid API返回的响应 - how can I get response returned by Plaid api using script 如何从jQuery $ .get方法读取返回的对象 - how can I read returned object from jQuery $.get method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM