-
글쓴이글
-
2022년 6월 16일 03:21 #36294
김대호참가자서버.js
db = client.db('notwait');
app.listen('8080', function () {
console.log('listening on 8080');
});
app.get('/Customer/:id', function (요청, 응답) {
응답.sendFile(path.join(__dirname, '/notwait/dist/index.html'));
});
app.get('/Owner', function (요청, 응답) {
응답.sendFile(path.join(__dirname, '/notwait/dist/index.html'));
});
app.post('/Login', function (요청, 응답) {
db.collection('code')
.find({ _id: 요청.body.code })
.toArray()
.then(data => {
if (data.length === 0) {
응답.send('Wrong information');
} else if (data[0].onoff == 1) {
var b = [];
db.collection('menu')
.find({ _id: 요청.body.code })
.toArray()
.then(a => {
b.push(a[0]);
});
db.collection('table')
.find({ _id: 요청.body.code })
.toArray()
.then(a => {
setTimeout(() => {
b.push(a[0]);
응답.send(b);
}, 500);
});
} else {
응답.send('Period is over');
}
});
});store.js
owner_login(context, payload) {
axios
.post(
'/Login',
{ code: payload },
{
onDownloadProgress: ProgressEvent => {
let percentage =
(ProgressEvent.loaded * 100) / ProgressEvent.total;
let percentcompleted = Math.round(percentage);
context.commit('owner_login_percentage', percentcompleted);
},
}
)
.then(response => {
if (response.data.length < 2) {
context.commit('owner_event_modalOnOff', 'Please reconnect');
} else if (response.data == 'Wrong information') {
context.commit('owner_event_modalOnOff', 'Wrong information');
} else if (response.data == 'Period is over') {
context.commit('owner_event_modalOnOff', 'Period is over');
} else {
context.commit('login', response);
}
});로컬호스트로는 잘 작동되던게
구글클라우드로 배포해서 접속하니 모든 post.get요청이 작동안하네요,...
ERR_QUIC_PROTOCOL_ERROR 200
502 오류도 뜨는데 어떻게 하나요?
ajax path부분을 할당받은주소/Owner 이런식으로 해야하나요?
2022년 6월 16일 12:26 #36322
김대호참가자다시보니 get ,post요청 잘되는것같습니다
근데
sse가 제대로 작동안하고(502 error),
onDownloadProgress: ProgressEvent => {
let percentage =
(ProgressEvent.loaded * 100) / ProgressEvent.total;
let percentcompleted = Math.round(percentage);get요청한걸 progressbar로 만들어서 사용중인데 이부분도 안되네요
app.get('/Owner/Sync', function (요청, res) {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
});
var 문서2;
const talk = db.collection('table').watch();
talk.on('change', result => {
문서2 = result.updateDescription.updatedFields;
var n = Object.keys(문서2).toString();
let num = Number(n.substr(6, 1));
res.write('event: test\n');
res.write('data: {\n');
res.write(`data: "data": ${JSON.stringify(문서2)},\n`);
res.write(`data: "index": ${num}\n`);
res.write('data: }\n\n');
});
}); -
글쓴이글
- 답변은 로그인 후 가능합니다.