16 lines
469 B
JavaScript
16 lines
469 B
JavaScript
|
|
const fs = require('fs');
|
||
|
|
const fetch = require('node-fetch') || global.fetch;
|
||
|
|
|
||
|
|
async function run() {
|
||
|
|
try {
|
||
|
|
const chatsRes = await fetch('http://localhost:3001/whatsapp/chats');
|
||
|
|
const chats = await chatsRes.json();
|
||
|
|
console.log('Total chats fetched:', chats.length);
|
||
|
|
fs.writeFileSync('all-chats-dump.json', JSON.stringify(chats, null, 2));
|
||
|
|
console.log('Saved all-chats-dump.json');
|
||
|
|
} catch (err) {
|
||
|
|
console.error('Error:', err);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
run();
|