我正在嘗試使用 javascript 構(gòu)建一個 API,以從此 URL 獲取數(shù)據(jù)以獲取 json 數(shù)據(jù): img, a, c 。但是下面的代碼拋出了一個錯誤application.js:10 Uncaught (in promise) TypeError: data.forEachis not a function(為什么forEach沒有定義方法)你能幫忙嗎?謝謝var results = document.getElementById("results");fetch("https://www.mangaeden.com/api/list/0/") .then(response => response.json()) .then((data) => { data.forEach((result) => { const movies = '<li><img src="' + result.im + '" alt=""><h3>' + result.a + '</h3><p>' + result.c + '</p></li>'; results.insertAdjacentHTML("beforeend", movies); }); });{ "a": "shoujo-apocalypse-adventure", "c": [ "Adventure", "Drama", "Psychological", "Sci-fi", "Seinen", "Slice of Life", "Tragedy" ], "h": 156, "i": "5c410d31719a16035a4647cc", "im": "4a/4a1f2a595e0e84e62f6ceddf3946274478928ca99e8df86bc6511b6e.png", "ld": 1547822837.0, "s": 2, "t": "Shoujo Apocalypse Adventure"},
如何使用javascript獲取api以顯示數(shù)據(jù)?
元芳怎么了
2021-06-10 13:12:48