Node app.js 를 통한 REDIS에서 데이타 조회 (SQLite DataBase에 저장되어진 시세데이타를 불러오기, 실시간이 아님)
1. index.html에서 app.js로 데이타포맷 보내기(SQLite DataBase에 저장되어진 시세데이타를 불러오기, 실시간이 아님)
async function sendData() {
const data = {
proto: "r",
sender: "1127001637919216845106",
id: "QUERY.0001574960.001",
ts: new Date().toISOString(),
method: "",
query: "A301S",
colcnt: ""
};
const response = await fetch('/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
}
2. REDIS에서 app.js 를 통한 JSON데이타 하나씩 꺼내오기
3 index.html에서 반복문을 통해서 하나씩 테이블에 출력
3.1 - index.html이 주된 메인이 되어서 control하므로, 반복문을 빠져나올수 있는 이벤트가 필요함
3.2 - JSON포맷중에 남은 항목에 서버에서 호출되어진 데이타의 Total개수를 표시
index++;
console.log(`Index: ${index}, Data Result: ${data.result}`);
if (data.result == index)
{
console.log(`Index: ${index}, Data Result: ${data.result}`);
console.log(`Index: ${index}, Data Result: ${data.result}`);
break;
}
4. 정상적으로 조회가 되는것을 확인
'java 언어 > Node.Server' 카테고리의 다른 글
Review.2024.10.10 (1) | 2024.10.10 |
---|---|
Node.Server/Index.HTML(2)+(3) (0) | 2024.10.10 |
Node app.js 를 통한 REDIS에서 데이타 추출(삭제후에 꺼내오기)(2) (0) | 2024.10.08 |
redis-cli에서 키/데이타수/데이타내용 확인명령어 (0) | 2024.09.30 |
Node.js 서버를 실행하고 클라이언트 측에서 실시간 데이터를 확인하는 방법입니다.(1) (0) | 2024.09.26 |