{ response.json().then((json) => { question_list = json; }); }); } get_question_list(); "> { response.json().then((json) => { question_list = json; }); }); } get_question_list(); "> { response.json().then((json) => { question_list = json; }); }); } get_question_list(); ">
<script>
  let question_list = [];

  function get_question_list() {
    fetch("<http://127.0.0.1:8000/api/question/list>").then((response) => {
      response.json().then((json) => {
        question_list = json;
      });
    });
  }

  get_question_list();
</script>

<ul>
  {#each question_list as question}
    <li>{question.subject}</li>
  {/each}
</ul>

Svelte 필수 문법

분기문

{#if 조건문1}
	<p>조건문1에 해당하면 실행</p>
{:else if 조건문2}
	<p>조건문2에 해당하면 실행</p>
{:else}
	<p>조건문2에 해당하면 실행</p>
{/if}

반복문

{#each list as item, index}
    <p>순서: {index} </p>
    <p>{item}</p>
{/each}

객체 표시

{객체}
{객체.속성}

필요한 화면