我是使用API的新手,我正在尝试为图片搜索返回一个值。Codepen Link
我试图在数组设置中获取thumbnailLink
的值,如下所示:
{
"items": [
{
"image": {
"thumbnailLink": "https://......"
这是我的JavaScript
$.getJSON(
"https://www.googleapis.com/customsearch/v1?key=AIzaSyCa8fDiJvEU6G3gYF9wQJiRRVp0eOXajGg&cx=006271532646749467732:ui1nmvdw2ba&searchType=image&q=" +
image,
function(google) {
var html = "";
var theImage = $.data(google.items[0].image.thumbnailLink);
$("#test");
google.forEach(function(val) {
var keys = Object.keys(val);
html += "<img src=";
keys.forEach(function(key) {
html += theImage;
});
html += ">";
});
}
);
},
它没有返回任何内容,并在控制台中给我这个错误。
Uncaught TypeError: Object.defineProperty called on non-object