This commit is contained in:
nkhangg 2025-03-19 14:48:30 +07:00
parent b1e34be9ce
commit 022a7a9733
1 changed files with 20 additions and 20 deletions

View File

@ -15,29 +15,29 @@ export class GrayApiBid extends ApiBid {
async polling(page) {
try {
// 🔥 Xóa tất cả event chặn request trước khi thêm mới
page.removeAllListeners('request');
await page.setRequestInterception(true);
// // 🔥 Xóa tất cả event chặn request trước khi thêm mới
// page.removeAllListeners('request');
// await page.setRequestInterception(true);
page.on('request', (request) => {
if (request.url().includes('api/Notifications/GetOutBidLots')) {
console.log('🚀 Fake response cho request:', request.url());
// page.on('request', (request) => {
// if (request.url().includes('api/Notifications/GetOutBidLots')) {
// console.log('🚀 Fake response cho request:', request.url());
const fakeData = fs.readFileSync('./data/fake-out-lots.json', 'utf8');
// const fakeData = fs.readFileSync('./data/fake-out-lots.json', 'utf8');
request.respond({
status: 200,
contentType: 'application/json',
body: fakeData,
});
} else {
try {
request.continue(); // ⚠️ Chỉ tiếp tục nếu request chưa bị chặn
} catch (error) {
console.error('⚠️ Lỗi khi tiếp tục request:', error.message);
}
}
});
// request.respond({
// status: 200,
// contentType: 'application/json',
// body: fakeData,
// });
// } else {
// try {
// request.continue(); // ⚠️ Chỉ tiếp tục nếu request chưa bị chặn
// } catch (error) {
// console.error('⚠️ Lỗi khi tiếp tục request:', error.message);
// }
// }
// });
console.log('🔄 Starting polling process...');