작성자 없음
작성자 정보가 삭제된 글입니다.
작성
·
320
0
let news = [];
const getLatestNews = async()=>{
let url = new URL(
`https://api.newscatcherapi.com/v2/search?q=Apple&from='2022/10/05'&countries=CA&page_size=10`);
let header = new Headers({
"x-api-key": "zpAatDWQatkuDD2G4_7OSLQt344GVruaD6Rav-u8tIc"
});
let response = await fetch(url, { headers:header });
let data = await response.json();
news = data.articles;
console.log(news);
render()
};
getLatestNews();
const render = ()=>{
let newsHTML = "";
newsHTML =news.map((item) => {
return `<div class="row news">
<div class="col-lg-4">
<img class="news-img-size" src="images/dish1.jpg" alt="">
</div>
<div class="col-lg-8">
<h1>헤드라인 제목</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ducimus repellendus, nobis at commodi explicabo ipsum deleniti sint quos quae tenetur, sed aspernatur consectetur quasi nostrum unde blanditiis ad quia iusto.
</p>
<div>
SBS * 2022-10-06
</div>
</div>
</div>`;
});
console.log(newsHTML);
document.getElementById("news-board").innerHTML = newsHTML;
};
getLatestNews();
왜 map이 안먹는지요 정말 이것때문에 하루종일 아무것도 안되고 있습니다... ㅠㅠㅠㅠ
답변 2
1
0
에러 메시지입니다.
Uncaught Error: Bootstrap's JavaScript requires jQuery
at bootstrap.min.js:6:37
api.newscatcherapi.com/v2/latest_headlines?countries=US&topic=business&page_size=10:1 Failed to load resource: the server responded with a status of 401 ()
1006-001.html:115 undefined
1006-001.html:122 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
at render (1006-001.html:122:29)
at getLatestNews (1006-001.html:117:13)
감사합니다.