작성
·
279
0
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
안녕하세요
코딩을 하다가 막히는 부분이 있어 질문드립니다.여기까지는 괜찮은데, 저 return ' ' 이 사이에 html코드를 끌고 오면 인식을 못하더군요
해결할 수 있는 방법이 있을까요?
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="container">
<section>
<div class="head-line">
<svg viewBox="0 0 184 25" fill="#000">
<path
d="M13.8 2.9c0-2-1.9-2.5-3.4-2.5v.3c.9 0 1.6.3 1.6 1 0 .4-.3 1-1.2 1-.7 0-2.2-.4-3.3-.8C6.2 1.4 5 1 4 1 2 1 .6 2.5.6 4.2c0 1.5 1.1 2 1.5 2.2l.1-.2c-.2-.2-.5-.4-.5-1 0-.4.4-1.1 1.4-1.1.9 0 2.1.4 3.7.9 1.4.4 2.9.7 3.7.8v3.1L9 10.2v.1l1.5 1.3v4.3c-.8.5-1.7.6-2.5.6-1.5 0-2.8-.4-3.9-1.6l4.1-2V6l-5 2.2C3.6 6.9 4.7 6 5.8 5.4l-.1-.3c-3 .8-5.7 3.6-5.7 7 0 4 3.3 7 7 7 4 0 6.6-3.2 6.6-6.5h-.2c-.6 1.3-1.5 2.5-2.6 3.1v-4.1l1.6-1.3v-.1l-1.6-1.3V5.8c1.5 0 3-1 3-2.9zm-8.7 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9 2 .2.3.7-.5.9 1.1v6.5l-1.3 1 .1.2.7-.5 2.2 2 3-2-.1-.3zm16.7-.1l-.7.5-1.1-1V9.3l1-.8-.2-.2-.8.7-2.3-2.1-3 2.1-2.3-2.1L154 9l-1.8-2.1-2.9 2 .1.3.7-.5 1 1.1v6.5l-.8.8 2.3 1.9 2.2-2-.9-.9V9.3l.9-.6 1.5 1.4v6l-.8.8 2.3 1.9 2.2-2-.9-.9V9.3l.8-.5 1.6 1.4v6l-.7.7 2.3 2.1 3.1-2.1v-.3zm8.7-1.5l-2.5 1.9-2.5-2v-1.2l4.7-3.2v-.1l-2.4-3.6-5.2 2.8v6.8l3.5 2.5 4.5-3.6-.1-.3zm-5-1.7V8.5l.2-.1 2.2 3.5-2.4 1.5zm14.1-.9l-1.9-1.5c1.3-1.1 1.8-2.6 1.8-3.6v-.6h-.2c-.2.5-.6 1-1.4 1-.8 0-1.3-.4-1.8-1L176 9.3v3.6l1.7 1.3c-1.7 1.5-2 2.5-2 3.3 0 1 .5 1.7 1.3 2l.1-.2c-.2-.2-.4-.3-.4-.8 0-.3.4-.8 1.2-.8 1 0 1.6.7 1.9 1l4.3-2.6v-3.6h-.1zm-1.1-3c-.7 1.2-2.2 2.4-3.1 3l-1.1-.9V8.1c.4 1 1.5 1.8 2.6 1.8.7 0 1.1-.1 1.6-.4zm-1.7 8c-.5-1.1-1.7-1.9-2.9-1.9-.3 0-1.1 0-1.9.5.5-.8 1.8-2.2 3.5-3.2l1.2 1 .1 3.6z">
</path>
</svg>
</div>
<div class="menus">
<button>Sport</button>
<button>Tech</button>
<button>World</button>
<button>Finance</button>
<button>Politics</button>
<button>Buisness</button>
<button>Economics</button>
<button>Beauty</button>
<button>Travel</button>
<button>Music</button>
<button>Food</button>
<button>Science</button>
<button>Gaming</button>
<button>Energy</button>
</div>
</section>
<section id="news-board">
<div class="row news">
<div class="col-lg-4">
<img class="news-img-size"
src="https://1.bp.blogspot.com/-zh5RklspYeY/Xo_G8IzTY1I/AAAAAAAALlM/kS-TcPxl3QMwrE6rCTIMTUxwBk8CxLqJgCLcBGAsYHQ/s1600/%25EB%25A6%25B4%25EB%25A6%25AC%25EC%2595%2588%2B%25E3%2583%25AA%25E3%2583%25AA%25E3%2582%25A2%25E3%2583%25B3%2BBunnie.png" />
</div>
<div class="col-lg-8">
<h2>
모여봐요 동물의 숲 릴리안은 귀엽다!
</h2>
<p>
아기토끼
</p>
<div>
news * 2022/12/01
</div>
</div>
</div>
</section>
</section>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script>
<script src="main.js"></script>
</body>
</html>
main.js
let news = [];
const getLatestNews = async () => {
let url = new URL('https://api.newscatcherapi.com/v2/latest_headlines?countries=US&topic=business&page_size=10');
let header = new Headers({ 'x-api-key': '1tDoWKJgyfjXBP2f2EnyYMdT_cStUgPJ0D5jOGYyUlM'});
let response = await fetch(url, { headers: header });
let data = await response.json();
news = data.articles;
console.log(news);
render();
};
const render =() => {
let newsHTML = "";
newsHTML = news.map((news)=>{
return '<div class="row news">
<div class="col-lg-4">
<img class="news-img-size"
src="https://1.bp.blogspot.com/-zh5RklspYeY/Xo_G8IzTY1I/AAAAAAAALlM/kS-TcPxl3QMwrE6rCTIMTUxwBk8CxLqJgCLcBGAsYHQ/s1600/%25EB%25A6%25B4%25EB%25A6%25AC%25EC%2595%2588%2B%25E3%2583%25AA%25E3%2583%25AA%25E3%2582%25A2%25E3%2583%25B3%2BBunnie.png" />
</div>
<div class="col-lg-8">
<h2>
모여봐요 동물의 숲 릴리안은 귀엽다!
</h2>
<p>
아기토끼
</p>
<div>
news * 2022/12/01
</div>
</div>
</div>';
}).join('');
console.log(newsHTML);
document.getElementById("news-board").innerHTML=newsHTML;
};
getLatestNews();