해결된 질문
작성
·
89
·
수정됨
0
세션 9. 여행지정보 최종프로젝트 작성 중...
CityList 개발 13:25분에서 CityList.js를 작성한 후 localhost:3000을 새로고침해도 전혀 변화없이 빈 화면만 출력이 됩니다!
api.js에서 API_URL로 전달받을 https://trip-wiki-api.vercel.app/ 에서 도시 정보 40개 정보가 없더라고요, 그래서 웹 화면에 아무것도 출력되지 않아서 문의드립니다!
server.js 파일도 /*splat 로 변경해서 "start server" 노드 명령어로 터미널에서 출력되도록 수정 완료했지만, 홈페이지 이미지가 출력되지 않고 있습니다!
const express = require("express");
const path = require("path");
const app = express();
const PORT = 3000;
app.use(express.static(path.join(__dirname, "..")));
app.get("/*splat", (req, res) => {
res.sendFile(path.join(__dirname, "..", "index.html"));
});
app.listen(PORT, () => {
console.log("START SEVER");
});
export default function CityList({ $app, initialState }) {
this.state = initialState;
this.$target = document.createElement("div");
this.$target.className = "city-list";
$app.appendChild(this.$target);
this.template = () => {
let temp = `<div class="city-items-container">`;
if (this.state) {
this.state.cities.forEach((elm) => {
temp += `
<div class="city-item" id=${elm.id}>
<img src=${elm.image}></img>
<div class="city-item-info">${elm.city}, ${elm.country}</div>
<div class="city-item-score">⭐ ${elm.total}</div>
</div>
`;
});
temp += `</div>`;
}
return temp;
};
this.render = () => {
this.$target.innerHTML = this.template();
};
this.setState = (newState) => {
this.state = newState;
this.render();
};
this.render();
}
답변 1
0
안녕하세요 안연수님!
https://trip-wiki-api.vercel.app/?start=0
강의에서 사용되는 api는 위와같이 start=startIdx 를 뒤에 작성해주어야합니다.
다만 수강생분들이 헷갈리지 않도록 https://trip-wiki-api 에도 접속 가능하게 변경해둔 상태이니, 다시 한 번 확인 부탁드릴게요! 감사합니다.