我是新手。当我在flickr公开API https://api.flickr.com/services/feeds/photos_public.gne?format=json#的api获取错误时,请有人帮助我。感谢您的帮助。
SyntaxError:“ JSON.parse:JSON数据第1行第1列的意外字符”
document.getElementById("activate").addEventListener("click", () => {
let play = document.getElementById("display");
let url = "https://api.flickr.com/services/feeds/photos_public.gne?format=json&tags=" + document.getElementById("txtsearch").value;
fetch(url)
.then(resp => resp.json())
.then(data => {
data.items.forEach((i) => {
const img = document.createElement("img");
img.src = i.media.m;
play.append(img);
})
})
.catch(error => console.error(error))
});
<label>Search</label>
<input id="txtsearch" type="text"></input>
<input type="button" id="activate" value="submit"></input>
<div id="display"></div>