亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用javascript獲取api以顯示數據?

如何使用javascript獲取api以顯示數據?

元芳怎么了 2021-06-10 13:12:48
我正在嘗試使用 javascript 構建一個 API,以從此 URL 獲取數據以獲取 json 數據: 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"},
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 266 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號