본문 바로가기
내일배움캠프

56. 내일배움캠프 - 44일차 TIL

by 새싹_v 2022. 11. 3.
728x90


 

 

TIL

 

📌
오늘 한 일

프로젝트 검색 기능 구현

오늘은 하루종일 검색 기능을 구현한 거 같다. 

해보지도 않은거라 정말 막막했다.

정말 하루종일 구글링 하고 유튜브 찾아보고 

검색만 엄청한거같다.

검색을 하다 보니 어느 정도 어떻게 해야 하는지 

감이 왔고 모르는 부분은 튜터님 도움을 많이 받았다.

결국엔 구현을 했다... 못할 줄 알았는데 되긴 하더라....

어제오늘 계속 머리를 쓰다 보니 간단한 것도 놓치고 

집중이 안됐다. 내일 산책이라도 나가야겠다 

그래도 기능이 구현되니깐 좋았다. (하면 되는구나....)

 

//알게된점

//검색기능 자바스크립트에서 fetch 사용할때
//아래처럼 const response = await fetch("http://127.0.0.1:8000/songs/search/"
//이렇게 주면 keyword를 백엔드에서 읽을 수 없다

async function searchclick(){
    var inputValue = document.getElementById('keyword').value;
    console.log(inputValue)
    const response = await fetch("http://127.0.0.1:8000/songs/search/"
   
   
   
//해결
//`http://127.0.0.1:8000/songs/search/?keyword=${inputValue}`
//inputValue를 담아서 전달해줘야함~!

async function searchclick(){
    var inputValue = document.getElementById('keyword').value;
    console.log(inputValue)
    const response = await fetch(`http://127.0.0.1:8000/songs/search/?keyword=${inputValue}`
728x90

댓글